Is there any way we can rewrite this query to run faster in DB2 7.2 :
INSERT INTO SESSION.TEMP_CLMCNT03
(
SELECT TMP_CLM.CLM_ID
,MIN(TMP_CLM.CLM_CVRG_ID)
,TMP_CLM.PROC_DT
FROM SESSION.TEMP_CLMCNT02 TMP_CLM
WHERE NOT EXISTS (
SELECT 1
FROM SESSION.TEMP_CLMCNT02 TMP_CLM1
WHERE TMP_CLM1.CLM_ID = TMP_CLM.CLM_ID
AND TMP_CLM1.PROC_DT = TMP_CLM.PROC_DT
AND TMP_CLM1.SRC_SYS_PROD_CD = TMP_CLM.SRC_SYS_PROD_CD
AND TMP_CLM1.RANK < TMP_CLM.RANK
)
GROUP BY TMP_CLM.CLM_ID
,TMP_CLM.SRC_SYS_PROD_CD
,TMP_CLM.PROC_DT
)
INSERT INTO SESSION.TEMP_CLMCNT03
(
SELECT TMP_CLM.CLM_ID
,MIN(TMP_CLM.CLM_CVRG_ID)
,TMP_CLM.PROC_DT
FROM SESSION.TEMP_CLMCNT02 TMP_CLM
WHERE NOT EXISTS (
SELECT 1
FROM SESSION.TEMP_CLMCNT02 TMP_CLM1
WHERE TMP_CLM1.CLM_ID = TMP_CLM.CLM_ID
AND TMP_CLM1.PROC_DT = TMP_CLM.PROC_DT
AND TMP_CLM1.SRC_SYS_PROD_CD = TMP_CLM.SRC_SYS_PROD_CD
AND TMP_CLM1.RANK < TMP_CLM.RANK
)
GROUP BY TMP_CLM.CLM_ID
,TMP_CLM.SRC_SYS_PROD_CD
,TMP_CLM.PROC_DT
)