Procedure performance

Hi,
Can any one please suggest how to increase performance of the below procedure as it is writing 20 records at a time.
CREATE OR REPLACE PROCEDURE NTFUNDPROC.TLM_AR_ASSET_PROOF_exp_SP (
P_PHONE IN VARCHAR2,
P_CLIENT IN VARCHAR2,
P_MANAGER IN VARCHAR2,
P_ACCOUNTANT IN VARCHAR2,
P_VALUE_DATE_D IN DATE,
P_INVMGR IN VARCHAR2,
PO_STCK_STOL_CUR OUT COMMON_PKG.REF_CUR
AS
PROCEDURE NAME:TLM_AR_STCK_REC_ASSET_PROOF_SP
**********************REVISION HISTORY*************************************
AUTHOR :TCS OFFSHORE TEAM
CREATED ON :2010-MAY-28
DESCRIPTION :PROVIDES OUR & THEIR SIDE ACTUAL AND DERIVED BALANCE INFORMATION
VERSION :1.0
/* DECLARATION OF VARIABLES */
P_PROCESSING_GROUP_C VARCHAR2(20);
P_CLIENT_C VARCHAR2(20);
P_MANAGER_C VARCHAR2(20);
P_ACCOUNTANT_C VARCHAR2(20);
P_ACC_NO_C VARCHAR2(60);
P_CORR_ACC_NO_N NUMBER;
P_COR_ACC_NO_N NUMBER;
P_STOCK_CODE_C VARCHAR2(140);
P_SEC_DESC_C VARCHAR2(200);
P_STOCK_ID_N NUMBER;
P_MATCH_NO_N NUMBER;
P_LS_TYPE_N NUMBER;
P_ENTRY_DATE DATE;
P_RUN_DATE DATE;
P_OUR_ISIN_N VARCHAR2(50);
P_OUR_SEDOL_N VARCHAR2(50);
P_OUR_CUSIP_N VARCHAR2(50);
P_OUR_STOCK_C VARCHAR2(50);
P_THEIR_STOCK_C VARCHAR2(50);
P_OUR_SIDE_ACTUAL_BAL_N NUMBER;
P_THEIR_SIDE_ACTUAL_BAL_N NUMBER;
P_OUR_SIDE_DIFFERENCE NUMBER;
P_OUR_SIDE_DERIVED_BAL_N NUMBER;
P_THEIR_SIDE_DERIVED_BAL_N NUMBER;
P_THEIR_SIDE_DIFFERENCE NUMBER;
P_CNTR_N NUMBER;
P_CNTR1_N NUMBER;
P_COMMS_C VARCHAR2(60);
P_SYS_ENTRY_DATE DATE;
P_LC_ACC_NO_C VARCHAR2(60);
P_VALUE_DATE DATE;
P_PARAM_DATE DATE;
P_OUR_SEC_DESC_C VARCHAR2(100);
P_THEIR_SEC_DESC_C VARCHAR2(100);
p_account_C VARCHAR2(200);
p_search_result_c number;
p_str_c varchar2(600);
p_sr_acc_result_c number;
p_sr_PG_result_c number;
p_sr_mgr_result_c number;
p_sr_clnt_result_c number;
p_str_clnt_c varchar2(500);
p_str_mgr_c varchar2(500);
p_str_PG_c varchar2(500);
p_str_acc_c varchar2(500);
p_our_side_n number;
p_their_side_n number;
p_our_derived_n number;
p_our_actual_n number;
p_their_derived_n number;
p_their_actual_n number;
/* DECLARATION OF CURSORS */
CURSOR FUND_PARAM IS
SELECT ACC_NO,VALUE_DATE FROM NTFUNDDBO.TLM_FUND_RPT_PARAM WHERE TRGNAME IN(SELECT PROCESSING_GROUP FROM TEMP_asset_proof_PG);
--and acc_no='1794371S' ;
CURSOR BANK_ITEM_CURSOR IS
SELECT distinct PHONE,FAX,TELEX,SWIFT_ADDR,BANK.LOCAL_ACC_NO,BANK.CORR_ACC_NO
FROM SSRFUND.BANK BANK
WHERE BANK.LOCAL_ACC_NO=P_LC_ACC_NO_C AND
BANK.PHONE IN(SELECT PROCESSING_GROUP FROM TEMP_asset_proof_PG) AND
BANK.FAX IN(SELECT manager FROM temp_asset_proof_mgr) AND
BANK.SWIFT_ADDR IN(SELECT client FROM temp_asset_proof_clnt) AND
BANK.TELEX IN(SELECT accountant FROM temp_asset_proof_acct) AND
BANK.PHONE >' '
order BY PHONE,FAX,TELEX,SWIFT_ADDR,BANK.LOCAL_ACC_NO,BANK.CORR_ACC_NO;
CURSOR ITEM_CURSOR IS
SELECT distinct Item.stock_id,t.stock_code,
decode(s.stock_desc,' ',t.stock_code||' (UNKNOWN)',null,t.stock_code||' (UNKNOWN)',s.stock_desc),max(value_date)
FROM SSRFUND.ITEM Item,ssrfund.stol t,ssrfund.stck s
where --Item.CORR_ACC_NO=100008390 and
Item.CORR_ACC_NO=p_corr_acc_no_n and
Item.stock_id=t.stock_id and
t.stock_id=s.stock_id(+) and
t.stock_code=s.stock_code(+) and
--t.stock_code='F851411' and
t.stock_code_type='0'
AND item.value_date<=p_sys_entry_Date
group by Item.stock_id,t.stock_code,
decode(s.stock_desc,' ',t.stock_code||' (UNKNOWN)',null,t.stock_code||' (UNKNOWN)',s.stock_desc);
cursor str_match_cursor is
WITH RES_SET AS
(SELECT
item.CORR_ACC_NO,
CASE WHEN ITEM.LS_TYPE IN (90,140,180)
THEN ITEM.string_21
ELSE ' ' END "ISIN",
CASE WHEN ITEM.LS_TYPE IN (90,140,180)
THEN ITEM.string_19
ELSE ' ' END "SEDOL",
CASE WHEN ITEM.LS_TYPE IN (90,140,180)
THEN ITEM.string_23
ELSE ' ' END "CUSIP",
CASE WHEN ITEM.LS_TYPE NOT IN (90,140,180)
THEN ITEM.sFIELD_8
ELSE ' ' END "THEIR_STOCK",
CASE WHEN ITEM.LS_TYPE IN (90,140,180)
THEN ITEM.SFIELD_8
ELSE ' ' END "OUR_STOCK",
CASE WHEN ITEM.LS_TYPE IN (90,140,180)
THEN ITEM.SFIELD_9
ELSE ' ' END "OUR_SECURITY_DESCRIPTION",
CASE WHEN ITEM.LS_TYPE not IN (90,140,180)
THEN ITEM.SFIELD_9
ELSE ' ' END "THEIR_SECURITY_DESCRIPTION",
SUM(CASE WHEN FLAG_2 IN (0,1)
THEN CASE WHEN LS_TYPE IN (90,180)
THEN ITEM.AMOUNT
WHEN LS_TYPE IN (140)
THEN -1*ITEM.AMOUNT
ELSE 0 END
ELSE 0
END) "OUR_SIDE_DERIVED",
SUM(CASE WHEN FLAG_2 = 4
AND trunc(ITEM.VALUE_DATE) = p_value_date--REPLACE INPUT DATE HERE
THEN CASE WHEN LS_TYPE IN (90,180)
THEN ITEM.AMOUNT
WHEN LS_TYPE IN (140)
THEN -1*ITEM.AMOUNT
ELSE 0 END
ELSE 0
END) "OUR_SIDE_ACTUAL",
SUM(CASE WHEN FLAG_2 IN (0,1)
AND LS_TYPE NOT IN (90,140,180,170,171,190)
THEN ITEM.AMOUNT
ELSE 0
END ) "THEIR_SIDE_DERIVED",
SUM(CASE WHEN FLAG_2 = 4
AND LS_TYPE NOT IN (90,140,180)
AND trunc(ITEM.VALUE_DATE) = p_value_date--REPLACE INPUT DATE HERE
THEN CASE WHEN LS_TYPE NOT IN (170,171,190)
THEN -1*ITEM.AMOUNT
ELSE ITEM.AMOUNT
END
ELSE 0
END) "THEIR_SIDE_ACTUAL"
FROM SSRFUND.ITEM item
WHERE item.corr_acc_no=P_CORR_ACC_NO_N AND
ITEM.SFIELD_8=P_STOCK_CODE_C
and (ITEM.FLAG_2 =0 or ITEM.FLAG_2 =1 or ITEM.FLAG_2 =4)
AND trunc(ITEM.VALUE_DATE) <= p_value_date
GROUP BY
item.CORR_ACC_NO,
cASE WHEN ITEM.LS_TYPE IN (90,140,180)
THEN ITEM.string_19
ELSE ' ' END ,
CASE WHEN ITEM.LS_TYPE IN (90,140,180)
THEN ITEM.string_21
ELSE ' ' END ,
CASE WHEN ITEM.LS_TYPE IN (90,140,180)
THEN ITEM.string_23
ELSE ' ' END ,
CASE WHEN ITEM.LS_TYPE NOT IN (90,140,180)
THEN ITEM.sFIELD_8
ELSE ' ' END,
CASE WHEN ITEM.LS_TYPE IN (90,140,180)
THEN ITEM.SFIELD_8
ELSE ' ' END,
CASE WHEN ITEM.LS_TYPE IN (90,140,180)
THEN ITEM.SFIELD_9
ELSE ' ' END ,
CASE WHEN ITEM.LS_TYPE not IN (90,140,180)
THEN ITEM.SFIELD_9
ELSE ' ' END
select NVL(ours.corr_acc_no,THEIRS.CORR_ACC_NO),
ours.ISIN,
ours.SEDOL,
ours.CUSIP,
Theirs.THEIR_STOCK,
OURS.OUR_STOCK,
OURS.OUR_SECURITY_DESCRIPTION,
THEIRS.THEIR_SECURITY_DESCRIPTION,
SUM(OURS.OUR_SIDE_DERIVED),
SUM(OURS.OUR_SIDE_ACTUAL),
SUM(THEIRS.THEIR_SIDE_DERIVED),
SUM(THEIRS.THEIR_SIDE_ACTUAL)
FROM RES_SET theirs left outer join RES_SET ours on
( theirs.CORR_ACC_NO = ours.CORR_ACC_NO)
where ( theirs.their_stock<>' ' or ours.our_stock<>' ')
and (THEIRS.THEIR_STOCK =OURS.OUR_STOCK or theirs.their_STOCK = ours.ISIN OR theirs.their_STOCK = ours.SEDOL OR
theirs.their_STOCK = ours.CUSIP )
GROUP BY NVL(ours.corr_acc_no,THEIRS.CORR_ACC_NO),ours.ISIN,
ours.SEDOL, ours.CUSIP,THEIRS.THEIR_STOCK,OURS.OUR_STOCK, OURS.OUR_SECURITY_DESCRIPTION,
THEIRS.THEIR_SECURITY_DESCRIPTION
union all
select NVL(ours.corr_acc_no,THEIRS.CORR_ACC_NO),
ours.ISIN,
ours.SEDOL,
ours.CUSIP,
Theirs.THEIR_STOCK,
OURS.OUR_STOCK,
OURS.OUR_SECURITY_DESCRIPTION,
THEIRS.THEIR_SECURITY_DESCRIPTION,
SUM(OURS.OUR_SIDE_DERIVED),
SUM(OURS.OUR_SIDE_ACTUAL),
SUM(THEIRS.THEIR_SIDE_DERIVED),
SUM(THEIRS.THEIR_SIDE_ACTUAL)
FROM RES_SET theirs , RES_SET ours where
( theirs.CORR_ACC_NO = ours.CORR_ACC_NO)
and ( theirs.their_stock<>' ' or ours.our_stock<>' ')
and (THEIRS.THEIR_STOCK <>OURS.OUR_STOCK and theirs.their_STOCK <>ours.ISIN and theirs.their_STOCK <> ours.SEDOL and
theirs.their_STOCK <> ours.CUSIP )
GROUP BY NVL(ours.corr_acc_no,THEIRS.CORR_ACC_NO),ours.ISIN,
ours.SEDOL, ours.CUSIP,THEIRS.THEIR_STOCK,OURS.OUR_STOCK, OURS.OUR_SECURITY_DESCRIPTION,
THEIRS.THEIR_SECURITY_DESCRIPTION ;
/* PROCESSING OF THE REPORT BEGINS */
BEGIN
/* DELETING THE ROWS FROM TEMPORARAY TABLE */
EXECUTE IMMEDIATE 'TRUNCATE TABLE TBL_ASSET_PROOF_exp_TEMP';
execute immediate 'truncate table temp_asset_proof_mgr_exp';
execute immediate 'truncate table temp_asset_proof_mgr_str_exp';
execute immediate 'truncate table temp_asset_proof_acct_exp';
execute immediate 'truncate table temp_asset_proof_acct_str_exp';
execute immediate 'truncate table temp_asset_proof_clnt_exp';
execute immediate 'truncate table temp_asset_proof_clnt_str_exp';
execute immediate 'truncate table temp_asset_proof_pg_exp';
execute immediate 'truncate table temp_asset_proof_pg_str_exp';
/* BASED ON VALUES OF INPUT PARAMETERS FOR LOCAL VARIABLES ASSUME VALUES AS FOLLOWS */
IF (P_PHONE IS NULL OR P_PHONE = COMMON_PKG.PG_ALL_CONST_C) THEN
INSERT INTO temp_asset_proof_pg_exp (select distinct PHONE from ssrfund.bank where phone>' ' );
commit;
ELSE
p_sr_PG_result_c:=instr(P_PHONE,',');
if ( p_sr_PG_result_c=0 ) then
P_PROCESSING_GROUP_C:= P_PHONE;
INSERT INTO temp_asset_proof_pg_exp values ( P_PROCESSING_GROUP_C);
commit;
else
p_sr_PG_result_c:=instr(P_PHONE,',');
if ( p_sr_PG_result_c<>0 ) then
p_str_PG_c := P_PHONE||',';
INSERT INTO temp_asset_proof_pg_STR_exp VALUES(p_str_PG_c);
COMMIT;
INSERT INTO temp_asset_proof_pg_exp
select substr( string_cOL
, decode( level, 1, 1, instr(string_cOL,',',1,level-1)+1)
, decode( instr(string_cOL,',',1,level), 0, length(string_cOL),
instr(string_cOL,',',1,level) - decode( level, 1, 0, instr(string_cOL,',',1,level-1))-1)
) the_value
from ( select string_cOL
from temp_asset_proof_pg_str_exp WHERE string_cOL>' ' )
connect by level <= length(string_cOL)-length(replace(string_cOL,','));
commit;
end if;
end if;
END IF;
IF (P_MANAGER IS NULL OR P_MANAGER = COMMON_PKG.PG_ALL_CONST_C) THEN
INSERT INTO temp_asset_proof_mgr_exp (select distinct fax from ssrfund.bank );
commit;
ELSE
p_sr_mgr_result_c:=instr(P_manager,',');
if ( p_sr_mgr_result_c=0 ) then
P_manager_C:= P_manager;
INSERT INTO temp_asset_proof_mgr_STR_exp values ( P_manager_C);
commit;
else
p_sr_mgr_result_c:=instr(P_manager,',');
if ( p_sr_mgr_result_c<>0 ) then
p_str_mgr_c := P_manager||',';
INSERT INTO temp_asset_proof_mgr_str_exp VALUES(p_str_mgr_c);
COMMIT;
INSERT INTO temp_asset_proof_mgr_exp
select substr( string_cOL
, decode( level, 1, 1, instr(string_cOL,',',1,level-1)+1)
, decode( instr(string_cOL,',',1,level), 0, length(string_cOL),
instr(string_cOL,',',1,level) - decode( level, 1, 0, instr(string_cOL,',',1,level-1))-1)
) the_value
from ( select string_cOL
from temp_asset_proof_mgr_str_exp WHERE string_cOL>' ' )
connect by level <= length(string_cOL)-length(replace(string_cOL,','));
commit;
end if;
end if;
END IF;
IF (P_ACCOUNTANT IS NULL OR P_ACCOUNTANT = COMMON_PKG.PG_ALL_CONST_C) THEN
INSERT INTO temp_asset_proof_acct_exp (select distinct telex from ssrfund.bank );
commit;
ELSE
p_sr_acc_result_c:=instr(P_ACCOUNTANT,',');
if ( p_sr_acc_result_c=0 ) then
P_ACCOUNTANT_C:= P_ACCOUNTANT;
INSERT INTO temp_asset_proof_acct_exp values ( P_ACCOUNTANT_C);
commit;
else
p_sr_acc_result_c:=instr(P_ACCOUNTANT,',');
if ( p_sr_acc_result_c<>0 ) then
p_str_acc_c := P_ACCOUNTANT||',';
INSERT INTO temp_asset_proof_acct_str_exp VALUES(p_str_acc_c);
COMMIT;
INSERT INTO temp_asset_proof_acct_exp
select substr( string_cOL
, decode( level, 1, 1, instr(string_cOL,',',1,level-1)+1)
, decode( instr(string_cOL,',',1,level), 0, length(string_cOL),
instr(string_cOL,',',1,level) - decode( level, 1, 0, instr(string_cOL,',',1,level-1))-1)
) the_value
from ( select string_cOL
from temp_asset_proof_acct_str_exp WHERE string_cOL>' ' )
connect by level <= length(string_cOL)-length(replace(string_cOL,','));
commit;
end if;
end if;
END IF;
IF (P_CLIENT IS NULL OR P_CLIENT = COMMON_PKG.PG_ALL_CONST_C) THEN
INSERT INTO temp_asset_proof_clnt_exp ( select distinct swift_addr from ssrfund.bank);
commit;
ELSE
p_sr_clnt_result_c:=instr(P_CLIENT,',');
if ( p_sr_clnt_result_c=0 ) then
P_CLIENT_C:= P_CLIENT;
INSERT INTO temp_asset_proof_clnt_exp values ( P_CLIENT_C);
commit;
else
p_sr_clnt_result_c:=instr(P_CLIENT,',');
if ( p_sr_clnt_result_c<>0 ) then
p_str_clnt_c := P_CLIENT||',';
INSERT INTO temp_asset_proof_clnt_str_exp VALUES(p_str_clnt_c);
COMMIT;
INSERT INTO temp_asset_proof_clnt_exp
select substr( string_cOL
, decode( level, 1, 1, instr(string_cOL,',',1,level-1)+1)
, decode( instr(string_cOL,',',1,level), 0, length(string_cOL),
instr(string_cOL,',',1,level) - decode( level, 1, 0, instr(string_cOL,',',1,level-1))-1)
) the_value
from ( select string_cOL
from temp_asset_proof_clnt_str_exp WHERE string_cOL>' ' )
connect by level <= length(string_cOL)-length(replace(string_cOL,','));
commit;
end if;
end if;
END IF;
IF P_VALUE_DATE_D IS NULL THEN
P_SYS_ENTRY_DATE:=SYSDATE;
ELSE
P_SYS_ENTRY_DATE:=P_VALUE_DATE_D;
END IF;
IF (P_INVMGR IS NULL OR P_INVMGR = COMMON_PKG.PG_ALL_CONST_C) THEN
P_COMMS_C:= COMMON_PKG.PG_LIKE_CONST_C;
ELSE
P_COMMS_C:= P_INVMGR;
END IF;
/* FETCHING ROWS FROM CURSORS */
OPEN FUND_PARAM;
LOOP
FETCH FUND_PARAM INTO P_LC_ACC_NO_C,P_PARAM_DATE;
EXIT WHEN (FUND_PARAM%NOTFOUND);
OPEN BANK_ITEM_CURSOR;
LOOP
FETCH BANK_ITEM_CURSOR INTO P_PROCESSING_GROUP_C,P_MANAGER_C, P_ACCOUNTANT_C,P_CLIENT_C,P_ACC_NO_C,P_CORR_ACC_NO_N;
EXIT WHEN (BANK_ITEM_CURSOR%NOTFOUND);
P_CNTR_N:=0;
OPEN ITEM_CURSOR;
LOOP
FETCH ITEM_CURSOR INTO P_STOCK_ID_N,P_STOCK_CODE_C,P_SEC_DESC_C,p_value_date;
EXIT WHEN (ITEM_CURSOR%NOTFOUND);
P_CNTR1_N:=0;
OPEN str_match_cursor;
loop
fetch str_match_cursor into P_COR_ACC_NO_N,P_OUR_ISIN_N,P_OUR_SEDOL_N,P_OUR_CUSIP_N,P_THEIR_STOCK_C,P_OUR_STOCK_C,
P_OUR_SEC_DESC_C,P_THEIR_SEC_DESC_C,P_OUR_SIDE_DERIVED_BAL_N,P_OUR_SIDE_ACTUAL_BAL_N,P_THEIR_SIDE_DERIVED_BAL_N,
P_THEIR_SIDE_ACTUAL_BAL_N;
EXIT WHEN (STR_MATCH_CURSOR%NOTFOUND);
P_CNTR_N:=P_CNTR_N+1;
P_CNTR1_N:=P_CNTR1_N+1;
INSERT INTO TBL_ASSET_PROOF_EXP_TEMP VALUES(P_PROCESSING_GROUP_C,P_MANAGER_C, P_ACCOUNTANT_C,P_CLIENT_C,P_ACC_NO_C,
P_CORR_ACC_NO_N,p_value_date,P_STOCK_ID_N,P_STOCK_CODE_C,P_STOCK_CODE_C,P_SEC_DESC_C,P_COR_ACC_NO_N,
P_OUR_ISIN_N,P_OUR_SEDOL_N,P_OUR_CUSIP_N,P_THEIR_STOCK_C,P_OUR_STOCK_C,P_OUR_SEC_DESC_C,P_THEIR_SEC_DESC_C,
P_OUR_SIDE_DERIVED_BAL_N,P_OUR_SIDE_ACTUAL_BAL_N,NULL,P_THEIR_SIDE_DERIVED_BAL_N,P_THEIR_SIDE_ACTUAL_BAL_N,
NULL,'ALL',sysdate);
COMMIT;
END LOOP;
CLOSE str_match_cursor;
IF P_CNTR1_N=0 THEN
INSERT INTO TBL_ASSET_PROOF_EXP_TEMP VALUES( P_PROCESSING_GROUP_C,P_MANAGER_C, P_ACCOUNTANT_C,P_CLIENT_C,P_ACC_NO_C,
P_CORR_ACC_NO_N,p_value_date,P_STOCK_ID_N,P_STOCK_CODE_C,P_STOCK_CODE_C,P_SEC_DESC_C,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,'ALL',sysdate);
COMMIT;
END IF;
END LOOP;
CLOSE ITEM_CURSOR;
IF P_CNTR_N=0 THEN
INSERT INTO TBL_ASSET_PROOF_EXP_TEMP VALUES( P_PROCESSING_GROUP_C,P_MANAGER_C, P_ACCOUNTANT_C,P_CLIENT_C,P_ACC_NO_C,
P_CORR_ACC_NO_N,p_value_date,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,null,'ALL',sysdate);
COMMIT;
END IF;
END LOOP;
CLOSE BANK_ITEM_CURSOR;
IF P_CORR_ACC_NO_N is null THEN
INSERT INTO TBL_ASSET_PROOF_EXP_TEMP VALUES( null,null, null,null,null,
null,null,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,null,null,null);
COMMIT;
END IF;
END LOOP;
CLOSE FUND_PARAM;
UPDATE TBL_ASSET_PROOF_EXP_TEMP SET OUR_SIDE_DIFFERENCE=(NVL(OUR_SIDE_DERIVED_BAL,0)-NVL(OUR_SIDE_ACTUAL_BAL,0)),
THEIR_SIDE_DIFFERENCE=(NVL(THEIR_SIDE_DERIVED_BAL,0)-NVL(THEIR_SIDE_ACTUAL_BAL,0))
WHERE OUR_SIDE_DIFFERENCE IS NULL AND THEIR_SIDE_DIFFERENCE IS NULL;
COMMIT;
/* SELECT ALL THE FIELDS OF TBL_ASSET_PROOF_TEMP FINAL OUTPUT REF CURSOR */
select SUM(NVL(OUR_SIDE_DERIVED_BAL,0)),SUM(NVL(OUR_SIDE_ACTUAL_BAL,0)),SUM(NVL(OUR_SIDE_DIFFERENCE,0)),
SUM(NVL(THEIR_SIDE_DERIVED_BAL,0)),SUM(NVL(THEIR_SIDE_ACTUAL_BAL,0)),SUM( NVL(THEIR_SIDE_DIFFERENCE,0))
into p_our_derived_n,p_our_actual_n,p_our_side_n,p_their_derived_n,p_their_actual_n,p_their_side_n
FROM NTFUNDPROC.TBL_ASSET_PROOF_EXP_TEMP;
if(p_our_derived_n<>0 and p_our_actual_n<>0 and p_our_side_n=0 and p_their_derived_n=0 and p_their_actual_n=0 and
p_their_side_n=0) then
OPEN PO_STCK_STOL_CUR FOR
select null PROCESSING_GROUP,null MANAGER,null ACCOUNTANT,null CLIENT,null LOCAL_ACC_NO,null CORR_ACC_NO,null VALUE_DATE,null STOCK_ID,
null STOCK_CODE,null PRIMARY_CODE,'No Exceptions to Report' SECURITY_DESC,null OUR_SIDE_DERIVED_BAL,null OUR_SIDE_ACTUAL_BAL,
null OUR_SIDE_DIFFERENCE,null THEIR_SIDE_DERIVED_BAL,null THEIR_SIDE_ACTUAL_BAL,null THEIR_SIDE_DIFFERENCE,null invmgr,null run_date
from TBL_ASSET_PROOF_EXP_TEMP;
else
OPEN PO_STCK_STOL_CUR FOR
SELECT distinct PROCESSING_GROUP,MANAGER,ACCOUNTANT,CLIENT,LOCAL_ACC_NO,CORR_ACC_NO,VALUE_DATE,NVL(STOCK_ID,0) STOCK_ID,
NVL(STOCK_CODE,0) STOCK_CODE,NVL(PRIMARY_CODE,0) PRIMARY_CODE ,SECURITY_DESC,
SUM(NVL(OUR_SIDE_DERIVED_BAL,0)) OUR_SIDE_DERIVED_BAL,SUM(NVL(OUR_SIDE_ACTUAL_BAL,0)) OUR_SIDE_ACTUAL_BAL,
SUM(NVL(OUR_SIDE_DIFFERENCE,0)) OUR_SIDE_DIFFERENCE,SUM(NVL(THEIR_SIDE_DERIVED_BAL,0)) THEIR_SIDE_DERIVED_BAL,
SUM(NVL(THEIR_SIDE_ACTUAL_BAL,0)) THEIR_SIDE_ACTUAL_BAL,SUM( NVL(THEIR_SIDE_DIFFERENCE,0)) THEIR_SIDE_DIFFERENCE,
invmgr,run_date
FROM NTFUNDPROC.TBL_ASSET_PROOF_EXP_TEMP
where (NVL(OUR_SIDE_DIFFERENCE,0))=0 or ( NVL(THEIR_SIDE_DIFFERENCE,0))=0
GROUP BY PROCESSING_GROUP,MANAGER,ACCOUNTANT,CLIENT,LOCAL_ACC_NO,CORR_ACC_NO,VALUE_DATE,NVL(STOCK_ID,0) ,
NVL(STOCK_CODE,0) ,NVL(PRIMARY_CODE,0) ,SECURITY_DESC,INVMGR,RUN_DATE
ORDER BY PROCESSING_GROUP,MANAGER,ACCOUNTANT,CLIENT,LOCAL_ACC_NO,CORR_ACC_NO,VALUE_DATE,
NVL(STOCK_ID,0),NVL(STOCK_CODE,0),NVL(PRIMARY_CODE,0);
end if;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR (-20001, SQLERRM);
END;
GRANT EXECUTE ON NTFUNDPROC.TLM_AR_ASSET_PROOF_exp_SP TO NTFUND_USER
/

user12852882 wrote:
can u suggest the any one of the logic.With the information given, no.
You need to provide the following information:
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Forms procedures Vs. Database schema procedures - performance question

    Hi,
    What performs more efficiently, a procedure coded in a program unit or trigger in a form, or the same logic coded in a database procedure?
    Eg:
    I have a proc in a form program unit that runs a select sentence and does some data manipulation before inserting records in a table . If I susbstitute this select statement for a view and the general process for a procedure in the database, will this perform faster?

    Hi there
    You have to consider if your procedure is computing-intensive or dml-intensive. For example Designer attaches to every form a set of 4-5 libraries. If you look at them, they work completely with forms predefined procedures and objets (they work with internal forms objects). This is an extreme case in which there isn´t any reason to have those libraries in the database (they wouldn´t compile anyway).
    If you have to do queries, insert, update and delete records, the logic should be in the database, as stored procedures, functions and packages.
    The good think is that from the form´s point of view, it doesn´t matter if a procedure is local to the form, inside an attached library or compiled in the database.
    So, I would go for stored procedures, functions and packages first. Only If the performance of the database is in risk would I consider to put transactional logic in libraries attached to forms.
    Good luck.

  • Stored procedure Performance issue in SQLserver 2005

    Hi All,
    i am inserting the data to Database by using of Stored procedure in target DB.
    My source structure and target structures are looking below
    I have the source structure having lot of rows and look like my structure is below:
    <?xml version="1.0" encoding="utf-8" ?>
    <ns0:POCA0013_KANLOG_REQUEST_MT_response xmlns:ns0="urn:com:POCA0013:sample">
    <SCMDB_response>
    -  <row>
          <PROJK>O-USA</PROJK>
          <KOLLO>123</KOLLO>
       </row>
    -  <row>
          <PROJK>O-Denmark</PROJK>
          <KOLLO>256</KOLLO>
       </row>
        n  number of rows
    </SCMDB_KANLOGVIEW_response>
    </ns0:POCA0013_KANLOG_REQUEST_MT_response>
    and after mapping my target structure is coming to like this.
    <?xml version="1.0" encoding="UTF-8" ?>
    <ns0:POCA0013_DB_MT xmlns:ns0="urn:pg-com POCA0013:sample">
    <StatmentName>
       <XI_SP_DATA action="EXECUTE">
         <PROJEK isInput="TRUE" type="CHAR">O-USA</PROJEK>
         <KOLLO isInput="TRUE" type="CHAR" >123</KOLLO>
       </XI_SP_DATA>
    </StatmentName>
    <StatmentName>
       <XI_SP_DATA action="EXECUTE">
         <PROJEK isInput="TRUE" type="CHAR">O-Denmark</PROJEK>
         <KOLLO isInput="TRUE" type="CHAR" />256</KOLLO>
       </XI_SP_DATA>
    </StatmentName>
      N number of times
    </ns0:POCA0013_DB_MT>
    this is working perfectly to insert the records into the database by using stored procedure. each record  it call the stored procedure for insert the records, for example we had 100 records and it call 100 times stored procedure.
    But in case of huge data, for example 10000 records, it call the 10000 times to stored procedure.in that case we had a problem for database side.
    we have  one reason to use the stored procedure here, because once insert the data into table, if successful log table is created with successful status , if not log table is created with error status. for that purpose i am using stored procedure here.
    Our customer wants to call the stored procedure for one time for all records.How i can manage this situation.
    Can you give me your valuble ideas about this problem.
    Thank you very much.,
    Sateesh
    Edited by: sateesh kumar .N on Apr 23, 2010 6:53 AM
    Edited by: sateesh kumar .N on Apr 23, 2010 6:54 AM
    Edited by: sateesh kumar .N on Apr 23, 2010 7:54 AM

    Hi Sateesh,
    how about a different approach.
    Add 2 more tables to your solution. The first table is used as a staging table, where PI inserts all the data without making any checks, whatsoever. The second table is used as a control table. If the insertion is finished, a log entry is inserted into this second table, containing the information about success or failure or how many rows had been inserted. Put an insert trigger on this table, which in term starts a stored procedure. This stored procedure can read all the data from the staging table and put it into the desired target tables. Additionally you can perform plausiblitiy checks inside this SP.
    Okay I know, this is a complete new solution in comparison to what you did before. But in my experience, this will be much more performant than 10000 calls to one stored procedure who only does inserts as you described.
    Regards
    Sven

  • Java stored procedures performance ....

    I am currently evaluating the use of Java stored procedures, but
    have so far found the performance to be incredibly poor. If I
    write a simple piece of SQL to insert 1 row to a 2 column table
    via a standalone JDBC application, the average elapsed time over
    5 runs is approx 24 milliseconds. If I move the same piece of
    code to a Java stored procedure, the elapsed time increases (on
    average) to 28 seconds ! Surely this shouldn't be the case; I
    had expected the performance to increase rather than plummet as
    is the case. The DBA team cannot find anything amiss in the
    database, & we are basically scratching our heads as to what the
    problem is. Is there something fundamental that needs to be done
    the database for a Java implementation ??
    ANY IDEAS ANYONE ???????
    nb: database ver 8.1.5, running on Solaris 5.7
    regards,
    Paul.
    null

    Try running long queries. In 8.1.6, we are concentrating more
    on increasing the performance of JDBC driver inside the server.
    Paul Jones (guest) wrote:
    : I am currently evaluating the use of Java stored procedures,
    but
    : have so far found the performance to be incredibly poor. If I
    : write a simple piece of SQL to insert 1 row to a 2 column table
    : via a standalone JDBC application, the average elapsed time
    over
    : 5 runs is approx 24 milliseconds. If I move the same piece of
    : code to a Java stored procedure, the elapsed time increases (on
    : average) to 28 seconds ! Surely this shouldn't be the case; I
    : had expected the performance to increase rather than plummet as
    : is the case. The DBA team cannot find anything amiss in the
    : database, & we are basically scratching our heads as to what
    the
    : problem is. Is there something fundamental that needs to be
    done
    : the database for a Java implementation ??
    : ANY IDEAS ANYONE ???????
    : nb: database ver 8.1.5, running on Solaris 5.7
    : regards,
    : Paul.
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Can I use an OLE DB Command Task to call a parameterized stored procedure, perform some data editing and pass variables back to the SSIS for handling?

    I am using a Data Flow and an OLE DB Source to read my staged 3rd party external data. I need to do various Lookups to try and determine if I can find the external person in our database...by SSN...By Name and DOB...etc...
    Now I need to do some more data verification based on the Lookup that is successful. Can I do those data edits against our SQL server application database by utilizing an OLE DB Command? Using a Stored Procedure or can I sue straight SQL to perform my edit
    against every staging row by using a parameter driven query? I'm thinking a Stored Procedure is the way to go here since I have multiple edits against the database. Can I pass back the result of those edits via a variable and then continue my SSIS Data Flow
    by analyzing the result of my Stored Procedure? And how would I do that.
    I am new to the SSIS game here so please be kind and as explicit as possible. If you know of any good web sites that walk through how to perform SQL server database edits against external data in SSIS or even a YouTube, please let me know.
    Thanks!

    Thanks for that...but can I do multiple edits in my Stored Procedure Vaibhav and pass back something that I can then utilize in my SSIS? For example...
    One and Only one Member Span...so I'd be doing a SELECT COUNT(*) based on my match criteria or handle the count accordingly in my Stored Procedure and passing something back via the OLE DB Command and handling it appropriately in SSIS
    Are there "Diabetes" claims...again probably by analyzing a SELECT COUNT(*)
    Am I expecting too much from the SSIS...should I be doing all of this in a Stored Procedure? I was hoping to use the SSIS GUI for everything but maybe that's just not possible. Rather use the Stored Procedure to analyze my stged data, edit accordingly, do
    data stores accordingly...especially the data anomalies...and then use the SSIS to control navigation
    Your thoughts........
    Could you maybe clarify the difference between an OLE DB Command on the Data Flow and the Execute SQL Task on the Control Flow...
    You can get return values from oledb comand if you want to pipeline.
    see this link for more details
    http://josef-richberg.squarespace.com/journal/2011/6/30/ssis-oledb-command-and-procedure-output-params.html
    The procedure should have an output parameter defined for that
    I belive if you've flexibility of using stored procedure you may be better off doing this in execute sql task in control flow. Calling sp in data flow will cause it to execute sp once for each row in dataset whereas in controlflow it will go for set based
    processing
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Bulk Insert Through Stored Procedure performance issue

    Hello,
    i am new to oracle. i am writing a stored procedure through which i want to insert 1 billion record in a table. but it takes days to insert it . please tell me how can i improve performance of my stored procedure. because same stored procedure when i convert it into sql server in take 24 - 30 min to insert 1 billion record.
    Code of my stored procedure are as follows :
    create or replace PROCEDURE bspGenerateHSCode(
    mLoc_id IN INT,
    HSCodeStart IN VARCHAR2,
    HSCodeEnd IN VARCHAR2,
    mRqstId IN INT,
    total_count IN INT,
    Status OUT INT)
    AS
    ExitFlag INT;
    row_count INT;
    mBatchStart NUMBER;
    mBatchEnd NUMBER;
    mStartSqnc NUMBER;
    mEndSqnc NUMBER;
    mHSCode VARCHAR2(500);
    HSStartStr VARCHAR2(500);
    BEGIN
    SELECT COUNT(*) INTO row_count FROM goap_eal_allocation
                   WHERE hs_code_start = HSCodeStart
    AND hs_code_end = HSCodeEnd
    AND loc_id = mLoc_id
    AND processed = 0;
    IF row_count > 0 THEN
    SELECT CAST ( REVERSE(substr(REVERSE(HSCodeStart), 1, instr(REVERSE(HSCodeStart), ',') -1)) AS NUMBER) INTO mStartSqnc FROM DUAL;
    SELECT CAST ( REVERSE(substr(REVERSE(HSCodeEnd), 1, instr(REVERSE(HSCodeEnd), ',') -1)) AS NUMBER) INTO mEndSqnc FROM DUAL;
    SELECT CAST( REVERSE(substr( REVERSE(HSCodeStart), instr(REVERSE(HSCodeStart), ','))) AS VARCHAR2(500) ) INTO HSStartStr FROM DUAL;
    mBatchStart := mStartSqnc;
    DBMS_OUTPUT.PUT_LINE('start batch ' || mBatchStart);
    LOOP
    mBatchEnd := mBatchStart + 5000;
    IF mBatchEnd > mEndSqnc THEN
    mBatchEnd := mEndSqnc + 1;
    END IF;
    DBMS_OUTPUT.PUT_LINE('End batch ' || mBatchEnd);
    LOOP
    mHSCode := HSStartStr || mBatchStart;
    mBatchStart := mBatchStart + 1;
    INSERT INTO goap_eal_register(id, hs_code, loc_id, status_id, synced)
    SELECT CASE WHEN MAX(id) > 0 THEN (MAX(id) + 1) ELSE 1 END AS id ,
    mHSCode, mLoc_id, 6, 1 FROM goap_eal_register;
    EXIT WHEN mBatchStart = mBatchEnd;
    END LOOP;
    COMMIT;
    EXIT WHEN mBatchStart = mEndSqnc +1;
    END LOOP;
    UPDATE goap_eal_allocation SET processed = 1
    WHERE hs_code_start = HSCodeStart
    AND hs_code_end = HSCodeEnd
    AND loc_id = mLoc_id;
    COMMIT;
    Status := 1;
    ELSE
    Status := 0;
    END IF;
    END;
    Thanks

    Please edit your post and add \ on the line before and the line after the code to preserve formattingsee how this looks?
    Also, when you basically just want to RETURN without doing any work then your first test should just RETURN if you don't want to do any work.
    Instead of what your code does:IF row_count > 0 THEN
    . . . a whole lot of code that is hard to read or understand
    COMMIT;
    Status := 1;
    ELSE
    Status := 0;
    END IF;
    Test the condition to determine when you do NOT want proceed and just return.IF row_count = 0 THEN
    Status := 0;
    RETURN;
    END IF;
    -- now NONE of the following code needs to be indented - you won't get here unless you really want to execute it.
    . . . break the code into separate steps and add a one line comment before each step that says what that step does.
    COMMIT;
    Status := 1;

  • Can someone help me diagnose a strange stored procedure performance issue please?

    I have a stored procedure (posted below) that returns message recommendations based upon the Yammer Networks you have selected. If I choose one network this query takes less than one second. If I choose another this query takes 9 - 12 seconds.
    /****** Object: StoredProcedure [dbo].[MessageView_GetOutOfContextRecommendations_LargeSet] Script Date: 2/18/2015 3:10:35 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE [dbo].[MessageView_GetOutOfContextRecommendations_LargeSet]
    -- Parameters
    @UserID int,
    @SourceMessageID int = 0
    AS
    BEGIN
    -- variable for @HomeNeworkUserID
    Declare @HomeNeworkUserID int
    -- Set the HomeNetworkID
    Set @HomeNeworkUserID = (Select HomeNetworkUserID From NetworkUser Where UserID = @UserID)
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON
    -- Begin Select Statement
    Select Top 40 [CreatedDate],[FileDownloadUrl],[HasLinkOrAttachment],[ImagePreviewUrl],[LikesCount],[LinkFileName],[LinkType],[MessageID],[MessageSource],[MessageText],[MessageWebUrl],[NetworkID],[NetworkName],[PosterEmailAddress],[PosterFirstName],[PosterImageUrl],[PosterName],[PosterUserName],[PosterWebUrl],[RepliesCount],[Score],[SmallIconUrl],[Subjects],[SubjectsCount],[UserID]
    -- From View
    From [MessageView]
    -- Do Not Return Any Messages That Have Been Recommended To This User Already
    Where [MessageID] Not In (Select MessageID From MessageRecommendationHistory Where UserID = @UserID)
    -- Do Not Return Any Messages Created By This User
    And [UserID] != @UserID
    -- Do Not Return The MessageID
    And [MessageID] != @SourceMessageID
    -- Only return messages for the Networks the user has selected
    And [NetworkID] In (Select NetworkID From NetworkUser Where [HomeNetworkUserID] = @HomeNeworkUserID And [AllowRecommendations] = 1)
    -- Order By [MessageScore] and [MessageCreatedDate] in reverse order
    Order By [Score] desc, [CreatedDate] desc
    ENDThe Actual Execution Plan Shows up the same; there are more messages on the Network that is slow, 2800 versus 1,500 but the difference is ten times longer on the slow network.Is the fact I am doing a Top 40 what makes it slow? My first guess was to take the Order By Off and that didn't seem to make any difference.The execution plan is below, it takes 62% of the query to look up theIX_Message.Score which is the clustered index, so I thought this would be fast. Also the Clustered Index Seek for the User.UserID take 26%which seems high for what it is doing.
    I have indexes on every field that is queried on so I am kind of at a loss as to where to go next.
    It just seems strange because it is the same view being queried in both cases.
    I tried to run the SQL Server Tuning Wizard but it doesn't run on Azure SQL, and my problem doesn't occur on the data in my local database.
    Thanks for any guidance, I know a lot of the slowness is due to the lower tier Azure SQL we are using, many of the performance issues weren't noticed when were on the full SQL Server, but the other networks work extremely fast so it has to be something to
    with having more rows.
    In case you need the SQL for the View that I am querying it is:
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE VIEW [dbo].[MessageView]
    AS
    SELECT M.UserID, M.MessageID, M.NetworkID, N.Name AS NetworkName, M.Subjects, M.SubjectsCount, M.RepliesCount, M.LikesCount, M.CreatedDate, M.MessageText, M.HasLinkOrAttachment, M.Score, M.WebUrl AS MessageWebUrl, U.UserName AS PosterUserName,
    U.Name AS PosterName, U.FirstName AS PosterFirstName, U.ImageUrl AS PosterImageUrl, U.EmailAddress AS PosterEmailAddress, U.WebUrl AS PosterWebUrl, M.MessageSource, M.ImagePreviewUrl, M.LinkFileName, M.FileDownloadUrl, M.LinkType, M.SmallIconUrl
    FROM dbo.Message AS M INNER JOIN
    dbo.Network AS N ON M.NetworkID = N.NetworkID INNER JOIN
    dbo.[User] AS U ON M.UserID = U.UserID
    GO
    The Network Table has an Index on Network ID, but it non clustered but I don't think that is the culprit.
    Corby

    I marked your response as answer because you gave me information I didn't have about the sort. I ended up rewriting the query to be a join instead of the In's and it improved dramatically, about one second on a very minimal Azure SQL database, and before
    it was 12 seconds on one network. We didn't notice the problem at all before we moved to Azure SQL, it was about one - three seconds at most.
    Here is the updated way that was much more efficient:
    CREATE PROCEDURE [dbo].[Procedure Name]
    -- Parameters
    @UserID int,
    @SourceMessageID int = 0
    AS
    BEGIN
    -- variable for @HomeNeworkUserID
    Declare @HomeNeworkUserID int
    -- Set the HomeNetworkID
    Set @HomeNeworkUserID = (Select HomeNetworkUserID From NetworkUser Where UserID = @UserID)
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON
    ;With cteMessages As
    -- Begin Select Statement
    Select (Fields List)
    -- Join to Network Table
    From MessageView mv Inner Join NetworkUser nu on MV.NetworkID = nu.NetworKID -- Only Return Networks This User Has Selected
    Where nu.HomeNetworkUserID = @HomeNeworkUserID And AllowRecommendations = 1
    -- Do Not Return Any Messages Created By This User
    And mv.[UserID] != @UserID
    -- Do Not Return The MessageID
    And mv.[MessageID] != @SourceMessageID
    ), cteHistoryForThisUser As
    Select MessageID From MessageRecommendationHistory Where UserID = @UserID
    -- Begin Select Statement
    Select Top 40 (Fields List)
    -- Join to Network Table
    From cteMessages m Left Outer Join cteHistoryForThisUser h on m.MessageID = h.MessageID
    -- Do Not Return Any Items Where User Has Already been shown this Message
    Where h.MessageID Is Null
    -- An Order By Is Needed To Get The Best Content First
    Order By Score Desc
    END
    GO
    The Left Outer Join to test for null was the biggest improvement, but it also helped to join to the NetworkUser table instead of do the In sub query.

  • How to improve stored procedure performance?

    hi,
    Suppose I have a stored procedure which contains 30 insert/update statements. How do I know Stored Procedure is slowly running or don't have any performance issue? how to improve performance?
    Thanks in advance.
    Anujit Karmakar Sr. Software Engineer

    Stored Procedures Optimization Tips
    Use stored procedures instead of heavy-duty queries.
    This can reduce network traffic, because your client will send to server only stored procedure name (perhaps with some parameters) instead of large heavy-duty queries text. Stored procedures can be used to enhance security and conceal underlying data objects
    also. For example, you can give the users permission to execute the stored procedure to work with the restricted set of the columns and data.
    Include the SET NOCOUNT ON statement into your stored procedures to stop the message indicating the number of rows affected by a Transact-SQL statement.
    This can reduce network traffic, because your client will not receive the message indicating the number of rows affected by a Transact-SQL statement.
    Call stored procedure using its fully qualified name.
    The complete name of an object consists of four identifiers: the server name, database name, owner name, and object name. An object name that specifies all four parts is known as a fully qualified name. Using fully qualified names eliminates any confusion about
    which stored procedure you want to run and can boost performance because SQL Server has a better chance to reuse the stored procedures execution plans if they were executed using fully qualified names.
    Consider returning the integer value as an RETURN statement instead of an integer value as part of a recordset.
    The RETURN statement exits unconditionally from a stored procedure, so the statements following RETURN are not executed. Though the RETURN statement is generally used for error checking, you can use this statement to return an integer value for any other reason.
    Using RETURN statement can boost performance because SQL Server will not create a recordset.
    Don't use the prefix "sp_" in the stored procedure name if you need to create a stored procedure to run in a database other than the master database.
    The prefix "sp_" is used in the system stored procedures names. Microsoft does not recommend to use the prefix "sp_" in the user-created stored procedure name, because SQL Server always looks for a stored procedure beginning with "sp_"
    in the following order: the master database, the stored procedure based on the fully qualified name provided, the stored procedure using dbo as the owner, if one is not specified. So, when you have the stored procedure with the prefix "sp_" in the
    database other than master, the master database is always checked first, and if the user-created stored procedure has the same name as a system stored procedure, the user-created stored procedure will never be executed.
    Use the sp_executesql stored procedure instead of the EXECUTE statement.
    The sp_executesql stored procedure supports parameters. So, using the sp_executesql stored procedure instead of the EXECUTE statement improve readability of your code when there are many parameters are used. When you use the sp_executesql stored procedure to
    executes a Transact-SQL statements that will be reused many times, the SQL Server query optimizer will reuse the execution plan it generates for the first execution when the change in parameter values to the statement is the only variation.
    Use sp_executesql stored procedure instead of temporary stored procedures.
    Microsoft recommends to use the temporary stored procedures when connecting to earlier versions of SQL Server that do not support the reuse of execution plans. Applications connecting to SQL Server 7.0 or SQL Server 2000 should use the sp_executesql system
    stored procedure instead of temporary stored procedures to have a better chance to reuse the execution plans.
    If you have a very large stored procedure, try to break down this stored procedure into several sub-procedures, and call them from a controlling stored procedure.
    The stored procedure will be recompiled when any structural changes were made to a table or view referenced by the stored procedure (for example, ALTER TABLE statement), or when a large number of INSERTS, UPDATES or DELETES are made to a table referenced by
    a stored procedure. So, if you break down a very large stored procedure into several sub-procedures, you get chance that only a single sub-procedure will be recompiled, but other sub-procedures will not.
    Try to avoid using temporary tables inside your stored procedure.
    Using temporary tables inside stored procedure reduces the chance to reuse the execution plan.
    Try to avoid using DDL (Data Definition Language) statements inside your stored procedure.
    Using DDL statements inside stored procedure reduces the chance to reuse the execution plan.
    Add the WITH RECOMPILE option to the CREATE PROCEDURE statement if you know that your query will vary each time it is run from the stored procedure.
    The WITH RECOMPILE option prevents reusing the stored procedure execution plan, so SQL Server does not cache a plan for this procedure and the procedure is recompiled at run time. Using the WITH RECOMPILE option can boost performance if your query will vary
    each time it is run from the stored procedure because in this case the wrong execution plan will not be used.
    Use SQL Server Profiler to determine which stored procedures has been recompiled too often.
    To check the stored procedure has been recompiled, run SQL Server Profiler and choose to trace the event in the "Stored Procedures" category called "SP:Recompile". You can also trace the event "SP:StmtStarting" to see at what point
    in the procedure it is being recompiled. When you identify these stored procedures, you can take some correction actions to reduce or eliminate the excessive recompilations.
    http://www.mssqlcity.com/tips/stored_procedures_optimization.htm
    Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/

  • Guided procedures performance

    I'm evaluating the performance of Guided procedures, in SAP Netweaver version 7.05 SP1. It runs over a machine with Intel Xeon @ 2.13 Ghz, 3.37 GB RAM, 2046 MB swap size, Windows Server 2003 Enterprise Edition, Service Pack 1, JRE version 1.5.0_11. The maximum JVM heap size is 1024 MB, using a parallel young garbage collection policy (-XX:+UseParNewGC), I'm using the parameter -XX
    :+HandlePromotionFailure in order to work around the bug 6226790 related to the UseParNewGC garbage collection option (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6226790).
    The test target is a "dummy" process, with one sequential block and three actions. The load is generated with JMeter, the test script creates a process instance, issuing a HTTP request to the corresponding URL. The load test consists in a increasing load of 1 to 20 concurrent virtual users, with a ramp-up time of 20 minutes (one new user every minute). The virtual users start process instances until the test is stopped (there is no defined iteration number), with a think time of 10 seconds.
    Till a load of 10 concurrent users the behavior is normal: constant response time about 500 ms and increasing throughput (considering the throughput as process instances started per second), until that moment about 300 process instances are created. However, as the test continues, the response time suddenly increases, the throughput falls and eventually the netweaver instance gets stuck. What is curious is that, although the netweaver instance is stuck, the utilization of the processor is low (less than 10%), as well as the memory (the heap just grows till 610 MB, its limit is 1024 MB). There are no sign of exhaustion of other resources, according to the corresponding performance counters (disk read and write queues, network utilization, context switches per second).
    The GP runtime is using the local workflow engine, the test has been repeated with 2, 4 and 8 threads in the workflow engine. In all the cases the above described results were almost the same.
    Does anybody know why the netweaver instance gets stuck under such conditions, and is there a way to solve this problem?
    Thanks in advance
    Edited by: Alexander Ambriz on Jan 13, 2008 4:34 PM

    The problem seems to be fixed in SP3.

  • Procedure performing a "Retry Secondary Site" Operation in SCCM 2012 R2 Secondary Server

    Dear Brother,
    My SCCM 2012 R2 Secondary Site Server, unfortunately crashed and required to be restored, doing this I end up performing a "Retry Secondary Site Operation.
    One by one I am clearing out the errors but there are few remaining errors on the prerequisite checks:
    1.[Failed]:The logon account for the SQL Server service cannot be a local user account, NT SERVICE\<sql service name> or LOCAL SERVICE.  You must configure the SQL Server service to use a valid domain account, NETWORK SERVICE, or LOCAL SYSTEM.
    Actions Done: SQL Related Services use Logon As Domain Account "Microsoft-Domain\BillAdmin" , but still the above message still appears in the logs.
    Actions Done: None
    2.[Failed]:The collation of the site database does not match the collation of the parent site's database.  All sites in a hierarchy must use the same database collation.
    3.[Failed]:The site server might be unable to publish to Active Directory. The computer account for the site server must have Full Control permissions to the System Management container in its Active Directory domain. You can ignore this warning if you have
    manually verified these permissions. For more information about your options to configure required permissions, see
    http://go.microsoft.com/fwlink/p/?LinkId=233190.
    Actions Done: None, as this machine is previously a working Secondary site for 1 Year already. So I do not suspect anything from the current related configuration.
    4.[Failed]: Either the user account running Configuration Manager Setup does not have sysadmin SQL Server role permissions on the SQL Server instance selected for site database installation, or the SQL Server instance could not be contacted to verify permissions.
    Setup cannot continue.
    Action Taken:  Domain Account "Microsoft-Domain\BillAdmin" has a
    Sysadmin roles and actually all the check boxes are chosen to acquire all SQL account roles" 
    5. [Failed]:Prerequisite checks complete with failure - check ConfigMgrPrereq.log
    in the root of the primary site server system drive.
    6[Failed]:Unable to complete secondary site server installation - check ConfigMgrSetup.log in the root of the secondary site server system drive.
    ConfigMgrPrereq.log-Start
    ?<12-27-2014 23:39:35> ********************************************
    ?<12-27-2014 23:39:35> ******* Start Prerequisite checking. *******
    ?<12-27-2014 23:39:35> ********************************************
    ?<12-27-2014 23:39:35> Commandline :
    "E:\Program Files\Microsoft Configuration Manager\bin\x64\smsexec.exe"
    ?<12-27-2014 23:39:35> Check Type: Secondary site
     Site Server: SecondarySite2.microsoft.com,
     SQL Server: SecondarySite2.microsoft.com,
     SQL Named Instance: MSSQLSERVER,
     Install Folder: E:\Program Files\Microsoft Configuration Manager\,
     Setup Source Folder: E:\Source\SCCM2012-R2
    ?<12-27-2014 23:39:35> INFO: Executing prerequisite functions...
    ?<12-27-2014 23:39:35> ===== INFO: Prerequisite Type & Server: SITE_SEC:SecondarySite2.microsoft.com =====
    ?<12-27-2014 23:39:35> <<<RuleCategory: Access Permissions>>>
    ?<12-27-2014 23:39:35> <<<CategoryDesc: Checking access permissions...>>>
    ?<12-27-2014 23:39:35> INFO: CheckLocalSys is Admin of <SecondarySite2.microsoft.com>.
    ?<12-27-2014 23:39:43> SecondarySite2.microsoft.com;    Site server computer account administrative rights;    Passed
    ?<12-27-2014 23:39:43> <<<RuleCategory: System Requirements>>>
    ?<12-27-2014 23:39:43> <<<CategoryDesc: Checking system requirements for ConfigMgr...>>>
    ?<12-27-2014 23:39:43> INFO: Check Lanman service: <SecondarySite2.microsoft.com>.
    ?<12-27-2014 23:39:44> SecondarySite2.microsoft.com;    Check Server Service is running;    Passed
    ?<12-27-2014 23:39:45> INFO: OS version:601, ServicePack:1.
    ?<12-27-2014 23:39:46> INFO: Target computer is a Windows server.
    ?<12-27-2014 23:39:46> SecondarySite2.microsoft.com;    Unsupported site server operating system version for Setup;    Passed
    ?<12-27-2014 23:39:46> SecondarySite2.microsoft.com;    Domain membership;    Passed
    ?<12-27-2014 23:39:47> INFO: Free disk space on target
    \\SecondarySite2.microsoft.com\E$\. = 83157 MB
    ?<12-27-2014 23:39:47> SecondarySite2.microsoft.com;    Free disk space on site server;    Passed
    ?<12-27-2014 23:39:47> SecondarySite2.microsoft.com;    Pending system restart;    Passed
    ?<12-27-2014 23:39:48> INFO: The server SecondarySite2.microsoft.com is not read-only domain controller.
    ?<12-27-2014 23:39:48> SecondarySite2.microsoft.com;    Read-Only Domain Controller;    Passed
    ?<12-27-2014 23:39:48> INFO: Check FQDN Length for site server: <SecondarySite2.microsoft.com>.
    ?<12-27-2014 23:39:48> SecondarySite2.microsoft.com;    Site Server FQDN Length;    Passed
    ?<12-27-2014 23:39:48> <<<RuleCategory: Dependent Components>>>
    ?<12-27-2014 23:39:48> <<<CategoryDesc: Checking dependent components for ConfigMgr...>>>
    ?<12-27-2014 23:39:48> SecondarySite2.microsoft.com;    Microsoft XML Core Services 6.0 (MSXML60);    Passed
    ?<12-27-2014 23:39:49> SecondarySite2.microsoft.com;    Microsoft Remote Differential Compression (RDC) library registered;    Passed
    ?<12-27-2014 23:39:49> INFO: Checking Windows Installer version on SecondarySite2.microsoft.com.
    ?<12-27-2014 23:39:50> INFO: Path of Windows Installer is <\\SecondarySite2.microsoft.com\C$\Windows\system32\msi.dll>.
    ?<12-27-2014 23:39:51> INFO: Msi.dll version is: <5.0.7601.17807> .
    ?<12-27-2014 23:39:51> SecondarySite2.microsoft.com;    Microsoft Windows Installer;    Passed
    ?<12-27-2014 23:39:51> INFO: Start Checking InstallSQLExpress on site server: SecondarySite2.microsoft.com, SQL Server instance MSSQLSERVER
    ?<12-27-2014 23:39:51> INFO: SQL Server Express installation was not selected.
    ?<12-27-2014 23:39:51> SecondarySite2.microsoft.com;    SQL Server Express on Secondary Site;    Passed
    ?<12-27-2014 23:39:52> SecondarySite2.microsoft.com;    Existing Configuration Manager server components on site server;    Passed
    ?<12-27-2014 23:39:52> SecondarySite2.microsoft.com;    Firewall exception for SQL Server (stand-alone primary site);    Passed
    ?<12-27-2014 23:39:52> INFO: SQL Server computer <SecondarySite2.microsoft.com>
    ?<12-27-2014 23:39:52> INFO: SQL Server named instance <MSSQLSERVER>
    ?<12-27-2014 23:39:53> SecondarySite2.microsoft.com;    SQL Server service running account;    Error;    The logon account for the SQL Server service cannot be a local user account, NT SERVICE\<sql service
    name> or LOCAL SERVICE.  You must configure the SQL Server service to use a valid domain account, NETWORK SERVICE, or LOCAL SYSTEM.
    ?<12-27-2014 23:39:53> INFO: SQL Server computer <SecondarySite2.microsoft.com>
    ?<12-27-2014 23:39:53> INFO: SQL Server named instance <MSSQLSERVER>
    ?<12-27-2014 23:39:53> INFO: Cannot connect to registry key.
    ?<12-27-2014 23:39:53> SecondarySite2.microsoft.com;    Dedicated SQL Server instance;    Passed
    ?<12-27-2014 23:39:53> INFO: CheckSQLCollationSecondary
    ?<12-27-2014 23:39:53> INFO: Collation on <PrimarySite2DB.microsoft.com> <SQL_Latin1_General_CP1_CI_AS>
    ?<12-27-2014 23:41:27> ERROR: failed to get collation from secondary site
    ?<12-27-2014 23:41:27> SecondarySite2.microsoft.com;    Parent/child database collation;    Error;    The collation of the site database does not match the collation of the parent site's database.  All
    sites in a hierarchy must use the same database collation.
    ?<12-27-2014 23:41:27> INFO: Checking .NET framework versions 3.5...
    ?<12-27-2014 23:41:28> INFO: .NET is installed
    ?<12-27-2014 23:41:28> SecondarySite2.microsoft.com;    Minimum .NET Framework version for Configuration Manager site server;    Passed
    ?<12-27-2014 23:41:28> INFO: Skipping check for .NET version, user did not select to install SQL Server Express for Secondary Site.
    ?<12-27-2014 23:41:28> SecondarySite2.microsoft.com;    Minimum .NET Framework version for SQL Server Express edition installation for Configuration Manager Secondary Site;    Passed
    ?<12-27-2014 23:41:28> INFO: CheckInstallSourceVersion <E:\Source\SCCM2012-R2>
    ?<12-27-2014 23:41:29> SecondarySite2.microsoft.com;    Setup Source Version;    Passed
    ?<12-27-2014 23:41:29> INFO:CheckInstallSourcePath <SecondarySite2.microsoft.com>
    ?<12-27-2014 23:42:14> SecondarySite2.microsoft.com;    Setup Source Folder;    Passed
    ?<12-27-2014 23:42:14> INFO: Enter CheckSecSiteSqlOnSameMachine.
    ?<12-27-2014 23:42:14> INFO: Target secondary site Machine <SecondarySite2.microsoft.com>
    ?<12-27-2014 23:42:14> INFO: SQL Server computer <SecondarySite2.microsoft.com>
    ?<12-27-2014 23:42:14> SecondarySite2.microsoft.com;    SQL Server on the Secondary Site Computer;    Passed
    ?<12-27-2014 23:42:14> INFO:CheckSupportedFQDNFormat <SecondarySite2.microsoft.com>
    ?<12-27-2014 23:42:15> INFO: NetBIOS <SECONDARYSITE2>
    ?<12-27-2014 23:42:15> SecondarySite2.microsoft.com;    Primary FQDN;    Passed
    ?<12-27-2014 23:42:15> INFO:CheckMachineAccountHasADAccess <SecondarySite2.microsoft.com>
    ?<12-27-2014 23:42:40> ERROR: Site server does not have create child permission on AD 'System Management'
    ?<12-27-2014 23:42:40> WARN: Site server does not have delete child permission on AD 'System Management'
    ?<12-27-2014 23:42:40> SecondarySite2.microsoft.com;    Verify site server permissions to publish to Active Directory.;    Warning;    The site server might be unable to publish to Active Directory. The computer
    account for the site server must have Full Control permissions to the System Management container in its Active Directory domain. You can ignore this warning if you have manually verified these permissions. For more information about your options to configure
    required permissions, see
    http://go.microsoft.com/fwlink/p/?LinkId=233190.
    ?<12-27-2014 23:42:40> INFO:CheckRemoteWMIConnection <SecondarySite2.microsoft.com>
    ?<12-27-2014 23:42:48> SecondarySite2.microsoft.com;    Remote Connection to WMI on Secondary Site;    Passed
    ?<12-27-2014 23:42:48> INFO: Check required collation of Sql Server.
    ?<12-27-2014 23:42:48> INFO: LangID <409>
    ?<12-27-2014 23:42:48> INFO: NOT primary site or CAS install, skipping check for reqired collation of SQL Server.
    ?<12-27-2014 23:42:48> SecondarySite2.microsoft.com;    Required SQL Server Collation;    Passed
    ?<12-27-2014 23:42:48> ===== INFO: Prerequisite Type & Server: SQL:SecondarySite2.microsoft.com =====
    ?<12-27-2014 23:42:48> <<<RuleCategory: Access Permissions>>>
    ?<12-27-2014 23:42:48> <<<CategoryDesc: Checking access permissions...>>>
    ?<12-27-2014 23:42:48> INFO:RemoteCheckAdminOnSQL <SecondarySite2.microsoft.com>, SQL Server <SecondarySite2.microsoft.com>
    ?<12-27-2014 23:44:33> SecondarySite2.microsoft.com;    SQL Server sysadmin rights;    Error;    Either the user account running Configuration Manager Setup does not have sysadmin SQL Server role permissions
    on the SQL Server instance selected for site database installation, or the SQL Server instance could not be contacted to verify permissions. Setup cannot continue.
    ?<12-27-2014 23:44:33> ===== INFO: Prerequisite Type & Server: MP:SecondarySite2.microsoft.com =====
    ?<12-27-2014 23:44:33> <<<RuleCategory: Access Permissions>>>
    ?<12-27-2014 23:44:33> <<<CategoryDesc: Checking access permissions...>>>
    ?<12-27-2014 23:44:33> SecondarySite2.microsoft.com;    Administrative share (Site system);    Passed
    ?<12-27-2014 23:44:33> INFO:CheckSiteSystemtoSQLConnectivity <SecondarySite2.microsoft.com>
    ?<12-27-2014 23:44:33> INFO: Installing secondary site, skipping SQL Server connectivity check.
    ?<12-27-2014 23:44:33> SecondarySite2.microsoft.com;    Site System to SQL Server Communication;    Passed
    ?<12-27-2014 23:44:33> <<<RuleCategory: System Requirements>>>
    ?<12-27-2014 23:44:33> <<<CategoryDesc: Checking system requirements for ConfigMgr...>>>
    ?<12-27-2014 23:44:33> INFO: The rule 'Check Server Service is running' has been run on server 'SecondarySite2.microsoft.com', skipped.
    ?<12-27-2014 23:44:34> INFO: OS version:601, ServicePack:1.
    ?<12-27-2014 23:44:35> INFO: Target computer is a Windows server.
    ?<12-27-2014 23:44:35> SecondarySite2.microsoft.com;    Unsupported management point operating system version for Setup;    Passed
    ?<12-27-2014 23:44:35> INFO: The rule 'Domain membership' has been run on server 'SecondarySite2.microsoft.com', skipped.
    ?<12-27-2014 23:44:36> INFO: Windows Cluster not found on SecondarySite2.microsoft.com.
    ?<12-27-2014 23:44:36> SecondarySite2.microsoft.com;    Windows Failover Cluster;    Passed
    ?<12-27-2014 23:44:36> INFO: The rule 'Pending system restart' has been run on server 'SecondarySite2.microsoft.com', skipped.
    ?<12-27-2014 23:44:36> <<<RuleCategory: Dependent Components>>>
    ?<12-27-2014 23:44:36> <<<CategoryDesc: Checking dependent components for ConfigMgr...>>>
    ?<12-27-2014 23:44:36> INFO: The rule 'Microsoft XML Core Services 6.0 (MSXML60)' has been run on server 'SecondarySite2.microsoft.com', skipped.
    ?<12-27-2014 23:44:36> SecondarySite2.microsoft.com;    IIS service running;    Passed
    ?<12-27-2014 23:45:35> INFO: CheckWebSvcExtnRemote, result:<7>.
    ?<12-27-2014 23:45:35> SecondarySite2.microsoft.com;    BITS installed;    Passed
    ?<12-27-2014 23:47:00> INFO: CheckWebSvcExtnRemote, result:<7>.
    ?<12-27-2014 23:47:01> WARN: BITS Service is not running on SecondarySite2.microsoft.com.
    ?<12-27-2014 23:47:01> SecondarySite2.microsoft.com;    BITS enabled;    Passed
    ?<12-27-2014 23:47:01> SecondarySite2.microsoft.com;    IIS HTTPS Configuration for management point;    Passed
    ?<12-27-2014 23:47:01> INFO: Stand-alone primary site or secondary site. Skip checking firewall settings for SQL Server
    ?<12-27-2014 23:47:01> SecondarySite2.microsoft.com;    Firewall exception for SQL Server for management point;    Passed
    ?<12-27-2014 23:47:01> SecondarySite2.microsoft.com;    Administrative rights on management point;    Passed
    ?<12-27-2014 23:47:01> INFO:CheckV4ClientNotInstalled <SecondarySite2.microsoft.com>
    ?<12-27-2014 23:47:45> SecondarySite2.microsoft.com;    Client Version on Management Point Computer;    Passed
    ?<12-27-2014 23:47:45> ===== INFO: Prerequisite Type & Server: DP:SecondarySite2.microsoft.com =====
    ?<12-27-2014 23:47:45> <<<RuleCategory: Access Permissions>>>
    ?<12-27-2014 23:47:45> <<<CategoryDesc: Checking access permissions...>>>
    ?<12-27-2014 23:47:45> <<<RuleCategory: System Requirements>>>
    ?<12-27-2014 23:47:45> <<<CategoryDesc: Checking system requirements for ConfigMgr...>>>
    ?<12-27-2014 23:47:47> SecondarySite2.microsoft.com;    Unsupported distribution point operating system version for Setup;    Passed
    ?<12-27-2014 23:47:47> INFO: The rule 'Domain membership' has been run on server 'SecondarySite2.microsoft.com', skipped.
    ?<12-27-2014 23:47:47> INFO: The rule 'Windows Failover Cluster' has been run on server 'SecondarySite2.microsoft.com', skipped.
    ?<12-27-2014 23:47:47> INFO: The rule 'Pending system restart' has been run on server 'SecondarySite2.microsoft.com', skipped.
    ?<12-27-2014 23:47:47> <<<RuleCategory: Dependent Components>>>
    ?<12-27-2014 23:47:47> <<<CategoryDesc: Checking dependent components for ConfigMgr...>>>
    ?<12-27-2014 23:47:47> SecondarySite2.microsoft.com;    Microsoft XML Core Services 6.0 (MSXML60) for distribution point;    Passed
    ?<12-27-2014 23:47:47> INFO: The rule 'IIS service running' has been run on server 'SecondarySite2.microsoft.com', skipped.
    ?<12-27-2014 23:47:47> SecondarySite2.microsoft.com;    IIS HTTPS Configuration for distribution point;    Passed
    ?<12-27-2014 23:47:47> SecondarySite2.microsoft.com;    Administrative rights on distribution point;    Passed
    ?<12-27-2014 23:47:48> ***************************************************
    ?<12-27-2014 23:47:48> ******* Prerequisite checking is completed. *******
    ?<12-27-2014 23:47:48> ***************************************************
    ?<12-27-2014 23:47:48> INFO: Updating Prerequisite checking result into the registry
    ?<12-27-2014 23:47:48> INFO: Connecting to SecondarySite2.microsoft.com registry
    ?<12-27-2014 23:47:50> INFO: Setting registry values
    ConfigMgrPrereq.log-End
    Well my question is what would be the best solutions as it bugs me for days now.
    Regards,

    Hello,
    ?<12-27-2014 23:44:33> SecondarySite2.microsoft.com;   
    SQL Server sysadmin rights;    Error;   
    Either the user account running Configuration Manager Setup does not have sysadmin SQL Server role permissions on the SQL Server instance selected for site database installation, or the SQL Server instance could not be contacted to verify permissions.
    Setup cannot continue.
    Did you install SQL server with a local account?
    ?<12-27-2014 23:41:27> SecondarySite2.microsoft.com;   
    Parent/child database collation;    Error;   
    The collation of the site database does not match the collation of the parent site's database. 
    All sites in a hierarchy must use the same database collation.
    Try this blog:
    http://jthys.wordpress.com/2012/04/02/sccm-2012-required-sql-server-collation/
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • A STORED PROCEDURE PERFORMES SLOWER WHEN EXECUTED IN HMTLDB THE IN SQLPLUS

    We executed a stored procedure in HTMLDB.
    At the beginning and the end of this stored procedure a timestamp inserted in a
    logtable. First we executed the procedure in HTMLDB's SQL workshop (version 2.0.0.00.49
    for MacOSX) under the owners schema .
    Execution time 17.61 seconds.
    When we query the table the logtable we see that this is the real execution time :
    Start: 29-01-07 10:12:17,000000
    Einde: 29-01-07 10:12:33,000000
    When executing the same procedure in SQLplus (as the schemeowner) the real execution
    time is less then a second :
    Start: 29-01-07 10:13:13,000000
    Einde: 29-01-07 10:13:13,000000
    Is there a difference in executing a stored procedure in HTMLDB and Sqlplus ?????

    Does it show the same timings if you execute the procedure first in Sql*Plus and then in APEX?
    Keep in mind that with your first run all your queries are parsed (create execution plans, ...) and that the data read is maybe stored in the SGA. So the second run can participate from that.
    Patrick
    Check out my APEX-blog: http://inside-apex.blogspot.com

  • Stored Procedure Performance Issue in Sharepoint Report

    We have a report stored procedure that runs in about 1 minute in production; however, when executed from the Sharepoint it populates, it runs for over 20 minutes, with exactly the same parameters. We've done everything to avoid parameter sniffing problems:
    used WITH RECOMPILE on the procedure declaration; added OPTION OPTIMIZE FOR UNKNOWN on the parameters within queries; even created local variables and assigned the parameter values to them and used them throughout the procedure. None of these has had any effect.
    I know that the 1-base minute run time is a big red flag, and we're working on pre-aggregating this data into our BI platform, but that's months down the liine and this is needed for month-end close every month.
    Other relevant information:
    Sharepoint 2013 on SQL Server 2012
    Data Source is a SQL Server 2008 R2 database
    Report definition created in Visual Studio 2008

    I'm trying to figure out why it's taking so long.  When I query on ExecutionLog3 I see the following (converted to seconds):
    Total Seconds
    Retrieval Seconds
    Processing Seconds
    Rendering Seconds
    ByteCount
    RowCount
    653.966
    653.933
    0.018
    0.015
    15037
    1
    Yet running in SSMS, it completes (consistently) in 62 seconds.

  • Procedure performance over db link

    In our source database, we are having one procedure that inserts data from one view and is inserting it into the another table.
    When we are running the procedure on this source system itself, it is getting executed in 3-4 mins
    Issue is coming when we are executing the procedure across database link.
    exec proc@source
    Plan is getting changed and is taking huge time. Are we hitting some bug or we have to stalablise the plan by addding hints is the only solution.
    Database version is 10.2.0.5
    Best Regards

    864411 wrote:
    In our source database, we are having one procedure that inserts data from one view and is inserting it into the another table.
    When we are running the procedure on this source system itself, it is getting executed in 3-4 mins
    Issue is coming when we are executing the procedure across database link.
    WHY across dblink?
    >
    >
    exec proc@source
    Plan is getting changed and is taking huge time. Doctor, it hurts when I poke myself in the eye.
    How can I get the pain to stop?
    So stop poking yourself in the eye!

  • PL/SQL procedure is 10x slower when running from weblogic

    Hi everyone,
    we've developed a PL/SQL procedure performing reporting - the original solution was written in Java but due to performance problems we've decided to switch this particular piece to PL/SQL. Everything works fine as long as we execute the procedure from SQL Developer - the batch processing 20000 items finishes in about 80 seconds, which is a serious improvement compared to the previous solution.
    But once we call the very same procedure (on exactly the same data) from weblogic, the performance seriously drops - instead of 80 seconds it suddenly runs for about 23 minutes, which is 10x slower. And we don't know why this happens :-(
    We've profiled the procedure (in both environments) using DBMS_PROFILER, and we've found that if the procedure is executed from Weblogic, one of the SQL statements runs noticeably slower and consumes about 800 seconds (90% of the total run time) instead of 0.9 second (2% of the total run time), but we're not sure why - in both cases this query is executed 32742-times, giving 24ms vs. 0.03ms in average.
    The SQL is
    SELECT personId INTO v_personId FROM (            
            SELECT personId FROM PersonRelations
            WHERE extPersonId LIKE v_person_prefix || '%'
    ) WHERE rownum = 1;Basically it returns an ID of the person according to some external ID (or the prefix of the ID). I do understand why this query might be a performance problem (LIKE operator etc.), but I don't understand why this runs quite fast when executed from SQL Developer and 10x slower when executed from Weblogic (exactly the same data, etc.).
    Ve're using Oracle 10gR2 with Weblogic 10, running on a separate machine - there are no other intensive tasks, so there's nothing that could interfere with the oracle process. According to the 'top' command, the wait time is below 0.5%, so there should be no serious I/O problems. We've even checked JDBC connection pool settings in Weblogic, but I doubt this issue is related to JDBC (and everything looks fine anyway). The statistics are fresh and the results are quite consistent.
    Edited by: user6510516 on 17.7.2009 13:46

    The setup is quite simple - the database is running on a dedicated database server (development only). Generally there are no 'intensive' tasks running on this machine, especially not when the procedure I'm talking about was executed. The application server (weblogic 10) is running on different machine so it does not interfere with the database (in this case it was my own workstation).
    No, the procedure is not called 20000x - we have a table with batch of records we need to process, with a given flag (say processed=0). The procedure reads them using a cursor and processes the records one-by-one. By 'processing' I mean computing some sums, updating other table, etc. and finally switching the record to processed=1. I.e. the procedure looks like this:
    CREATE PROCEDURE process_records IS
        v_record records_to_process%ROWTYPE;
    BEGIN
         OPEN records_to_process;
         LOOP
              FETCH records_to_process INTO v_record;
              EXIT WHEN records_to_process%NOTFOUND;
              -- process the record (update table A, insert a record into B, delete from C, query table D ....)
              -- and finally mark the row as 'processed=1'
         END LOOP;
         CLOSE records_to_process;
    END process_records;The procedure is actually part of a package and the cursor 'records_to_process' is defined in the body. One of the queries executed in the procedure is the SELECT mentioned above (the one that jumps from 2% to 90%).
    So the only thing we actually do in Weblogic is
    CallableStatement cstmt = connection.prepareCall("{call ProcessPkg.process_records}");
    cstmt.execute();and that's it - there is only one call to the JDBC, so the network overhead shouldn't be a problem.
    There are 20000 rows we use for testing - we just update them to 'processed=0' (and clear some of the other tables). So actually each run uses exactly the same data, same code paths and produces the very same results. Yet when executed from SQL developer it takes 80 seconds and when executed from Weblogic it takes 800 seconds :-(
    The only difference I've just noticed is that when using SQL Developer, we're using PL/SQL notation, i.e. "BEGIN ProcessPkg.process_records; END;" instead of "{call }" but I guess that's irrelevant. And yet another difference - weblogic uses JDBC from 10gR2, while the SQL Developer is bundled with JDBC from 11g.

  • How to extract multiple values from a procedure

    Hi, i have a plsql procedure that i have to invoque in a select statement. This procedure return several values (it has multiple OUTPUTS). How can i get this values and how they are returned.
    Thanks

    Hi. This procedure performs a series of calculations and it is used in a userform (forms). Now we need to used to construct a report. Reading the procedure code, in the parameters list apears several (5 to be exact) parameters that are OUTPUTS (are describe like this in the documentation). I don´t know about plsql but i don´t know if there are any way to send parameters by reference to a procedure.
    Another question, how can i invoque it?
    Thanks.

Maybe you are looking for