我正在开展一项任务,我需要优化或调整sybase中的过程。我之前没有做过这种事,所以任何人都可以帮助我..
我认为下面提到的程序部分需要花费太多时间 -
DECLARE @lnTotalCount INT
---This returns 953 rows-----
SELECT @lnTotalCount = COUNT(*) FROM
firstTable chksts
SELECT @lnRecordCount = 1, @lnRowsProcessed =0
WHILE @lnRecordCount <= @lnTotalCount
BEGIN
-- SET ROWCOUNT 1
SELECT @lcCKPY_REF_ID = ckck.CKPY_REF_ID,
@lnCKCK_SEQ_NO = ckck.CKCK_SEQ_NO,
@lcPYPY_ID = ckck.PYPY_ID,
@lnCKCK_CK_NO = ckck.CKCK_CK_NO,
@ldtCKCK_CASHED_DT = ckck.CKCK_CASHED_DT,
@ldtCKCK_PRINTED_DT = ckck.CKCK_PRINTED_DT,
@ldtCKCK_REISS_DT = ckck.CKCK_REISS_DT,
@lcCKCK_TYPE = ckck.CKCK_TYPE,
@lcCKCK_PAYEE_NAME = ckck.CKCK_PAYEE_NAME,
@lcCKCK_CURR_STS = LTRIM(RTRIM(chksts.[TRANSACTION])),
@lnCKST_SEQ_NO = ckck.CKST_SEQ_NO,
@lcCKCK_REISS_USUS_ID = ckck.CKCK_REISS_USUS_ID,
@lnCKCK_LOCK_TOKEN = ckck.CKCK_LOCK_TOKEN,
@ldtATXR_SOURCE_ID = ckck.ATXR_SOURCE_ID,
@lnBPID_CK_NO = chksts.SERIAL_NUMBER
FROM
firstTable chksts,
secondTable ckck,
thirdTable bpid
WHERE ckck.CKPY_REF_ID = bpid.CKPY_REF_ID
AND bpid.BPID_CK_NO = chksts.SERIAL_NUMBER
AND ckck.CKCK_SEQ_NO = bpid.CKCK_SEQ_NO
AND ckck.CKCK_CURR_STS IN ('03','X3')
AND chksts.ID = @lnRecordCount
IF(@@ROWCOUNT<>0) /* 1.5 If-Else condition*/
BEGIN
EXEC @lnRetCd = ABProcedure
NULL,
NULL,
@lcCKPY_REF_ID,
@lnCKCK_SEQ_NO,
@lcPYPY_ID,
@lnCKCK_CK_NO,
@ldtCKCK_CASHED_DT,
@ldtCKCK_PRINTED_DT,
@ldtCKCK_REISS_DT,
@lcCKCK_TYPE,
@lcCKCK_PAYEE_NAME,
@lcCKCK_CURR_STS,
@lnCKST_SEQ_NO,
@lcCKCK_REISS_USUS_ID,
@lnCKCK_LOCK_TOKEN,
@ldtATXR_SOURCE_ID
SELECT @lnRowsProcessed = @lnRowsProcessed + @@ROWCOUNT
SELECT @lnRecordCount = @lnRecordCount + 1
摘要:此过程有一个部分,它根据上面选择的值调用另一个过程(ABprocedure)....
任何改善表现的建议......此刻它需要超过5个小时...