nicemanish
asked on
Oracle stored procedure performance
Hi,
For below sp having a performance issue,if i am passing all parameter its work fine ,but when pass 2 or 3 parameter its goes to time out.expert plz look and provide to improve performance might be work on join."this sp is only checking duplicate records in DB"
-------------------------- ---------- ---------- ---------- ---------- ---------- -
create or replace PROCEDURE SP_Duplicate
(
pi_meme_ssn IN INT,
pi_meme_first_nm IN VARCHAR2,
pi_meme_last_nm IN VARCHAR2,
pi_meme_birth_dt IN DATE,
pi_meme_city IN VARCHAR2,
pi_meme_state IN VARCHAR2,
pi_sbad_zip_cd IN VARCHAR2,
pi_grgrck_no IN INT,
po_return_value OUT VARCHAR2
)
IS
vl_total_cnt INT;
BEGIN
/* On the basis of the input parameters validation of DUPCHK process is done */
IF pi_meme_ssn = 0
AND pi_meme_first_nm IS NULL
AND pi_meme_last_nm IS NULL
AND pi_meme_birth_dt IS NULL
AND pi_meme_city IS NULL
AND pi_meme_state IS NULL
AND pi_sbad_zip_cd IS NULL
AND pi_grgrck_no = 0 THEN
po_return_value :='N';
ELSE
SELECT COUNT(1)
INTO vl_total_cnt
FROM cmc_meme_member meme,
cmc_mepe_prcs_elig mepe,
cmc_sbad_addr sbad
WHERE meme.meme_ck = mepe.meme_ck
AND mepe.mepe_elig_ind = 'Y'
--AND SYSDATE BETWEEN mepe.MEPE_EFF_DT AND mepe.MEPE_TERM_DT
AND meme.meme_ssn = NVL(DECODE(pi_meme_ssn,0,N ULL,pi_mem e_ssn),mem e.meme_ssn )
AND LOWER(meme.meme_first_name ) = NVL(LOWER(pi_meme_first_nm ),LOWER(me me.meme_fi rst_name))
AND LOWER(meme.meme_last_name) = NVL(LOWER(pi_meme_last_nm) ,LOWER(mem e.meme_las t_name))
AND meme.meme_birth_dt = NVL(decode(pi_meme_birth_d t,'',NULL, pi_meme_bi rth_dt),me me.meme_bi rth_dt)
AND meme.grgr_ck = NVL(DECODE(pi_grgrck_no,0, NULL,pi_gr grck_no),m eme.grgr_c k)
AND LOWER(sbad.sbad_city) = NVL(LOWER(pi_meme_city),LO WER(sbad.s bad_city))
AND LOWER(sbad.sbad_state) = NVL(LOWER(pi_meme_state),L OWER(sbad. sbad_state ))
AND sbad.sbad_zip = NVL(pi_sbad_zip_cd,sbad.sb ad_zip)
AND sbad.grgr_ck = meme.grgr_ck;
/* If the count is greater than or equal to 1 then the output will be 'Y' that is duplicate */
IF vl_total_cnt >= 1 THEN
po_return_value :='Y';
ELSE
/* If the count is equal to 0 then the output will be 'N' that is not a duplicate */
po_return_value :='N';
END IF;
END IF;
END;
For below sp having a performance issue,if i am passing all parameter its work fine ,but when pass 2 or 3 parameter its goes to time out.expert plz look and provide to improve performance might be work on join."this sp is only checking duplicate records in DB"
--------------------------
create or replace PROCEDURE SP_Duplicate
(
pi_meme_ssn IN INT,
pi_meme_first_nm IN VARCHAR2,
pi_meme_last_nm IN VARCHAR2,
pi_meme_birth_dt IN DATE,
pi_meme_city IN VARCHAR2,
pi_meme_state IN VARCHAR2,
pi_sbad_zip_cd IN VARCHAR2,
pi_grgrck_no IN INT,
po_return_value OUT VARCHAR2
)
IS
vl_total_cnt INT;
BEGIN
/* On the basis of the input parameters validation of DUPCHK process is done */
IF pi_meme_ssn = 0
AND pi_meme_first_nm IS NULL
AND pi_meme_last_nm IS NULL
AND pi_meme_birth_dt IS NULL
AND pi_meme_city IS NULL
AND pi_meme_state IS NULL
AND pi_sbad_zip_cd IS NULL
AND pi_grgrck_no = 0 THEN
po_return_value :='N';
ELSE
SELECT COUNT(1)
INTO vl_total_cnt
FROM cmc_meme_member meme,
cmc_mepe_prcs_elig mepe,
cmc_sbad_addr sbad
WHERE meme.meme_ck = mepe.meme_ck
AND mepe.mepe_elig_ind = 'Y'
--AND SYSDATE BETWEEN mepe.MEPE_EFF_DT AND mepe.MEPE_TERM_DT
AND meme.meme_ssn = NVL(DECODE(pi_meme_ssn,0,N
AND LOWER(meme.meme_first_name
AND LOWER(meme.meme_last_name)
AND meme.meme_birth_dt = NVL(decode(pi_meme_birth_d
AND meme.grgr_ck = NVL(DECODE(pi_grgrck_no,0,
AND LOWER(sbad.sbad_city) = NVL(LOWER(pi_meme_city),LO
AND LOWER(sbad.sbad_state) = NVL(LOWER(pi_meme_state),L
AND sbad.sbad_zip = NVL(pi_sbad_zip_cd,sbad.sb
AND sbad.grgr_ck = meme.grgr_ck;
/* If the count is greater than or equal to 1 then the output will be 'Y' that is duplicate */
IF vl_total_cnt >= 1 THEN
po_return_value :='Y';
ELSE
/* If the count is equal to 0 then the output will be 'N' that is not a duplicate */
po_return_value :='N';
END IF;
END IF;
END;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER