Hi ,
Below Mention Query is running in Orlace however i now this not correct place to ask oracle question here .
anyone can suggest how i can tune below mention query because it's taking 5 hrs in oracle .I have created index for all group by columns .
Delete From RX_IN where ROWID IN (
SELECT RX1.ROWID FROM ( SELECT MBR_KEY, RX_NDC, RX_FILLED_DT , RX_NBR, FILLED_REFILS_NBR, CLM_NBR, CLM_DISP_CD,
ROW_NUMBER() OVER(PARTITION BY MBR_KEY, RX_NDC, RX_FILLED_DT, RX_NBR, FILLED_REFILS_NBR, CLM_NBR,CLM_DISP_CD
ORDER BY MBR_KEY, RX_NDC, RX_FILLED_DT, RX_NBR, FILLED_REFILS_NBR, CLM_NBR, CLM_DISP_CD) AS CHECKING FROM RX_IN WHERE CLM_DISP_CD='ORGNL' ) RX1
INNER JOIN ( SELECT MBR_KEY, RX_NDC, RX_FILLED_DT, RX_NBR, FILLED_REFILS_NBR, CLM_NBR, CLM_DISP_CD,
ROW_NUMBER() OVER(PARTITION BY MBR_KEY, RX_NDC, RX_FILLED_DT, RX_NBR, FILLED_REFILS_NBR, CLM_NBR,CLM_DISP_CD
ORDER BY MBR_KEY, RX_NDC, RX_FILLED_DT, RX_NBR, FILLED_REFILS_NBR, CLM_NBR, CLM_DISP_CD) AS CHECKING FROM RX_IN WHERE CLM_DISP_CD='RVRSL' ) RX2
ON RX1.MBR_KEY= RX2.MBR_KEY AND RX1.RX_NDC = RX2.RX_NDC AND RX1.RX_FILLED_DT=RX2.RX_FILLED_DT AND RX1.RX_NBR=RX2.RX_NBR AND RX1.FILLED_REFILS_NBR=RX2.FILLED_REFILS_NBR
AND RX1.CLM_NBR=RX2.CLM_NBR AND RX1.CHECKING=RX2.CHECKING
UNION
SELECT RX2.ROWID FROM ( SELECT MBR_KEY, RX_NDC, RX_FILLED_DT , RX_NBR, FILLED_REFILS_NBR, CLM_NBR, CLM_DISP_CD,
ROW_NUMBER() OVER(PARTITION BY MBR_KEY, RX_NDC, RX_FILLED_DT, RX_NBR, FILLED_REFILS_NBR, CLM_NBR,CLM_DISP_CD
ORDER BY MBR_KEY, RX_NDC, RX_FILLED_DT, RX_NBR, FILLED_REFILS_NBR, CLM_NBR, CLM_DISP_CD) AS CHECKING FROM RX_IN WHERE CLM_DISP_CD='ORGNL' ) RX1
INNER JOIN ( SELECT MBR_KEY, RX_NDC, RX_FILLED_DT, RX_NBR, FILLED_REFILS_NBR, CLM_NBR, CLM_DISP_CD,
ROW_NUMBER() OVER(PARTITION BY MBR_KEY, RX_NDC, RX_FILLED_DT, RX_NBR, FILLED_REFILS_NBR, CLM_NBR,CLM_DISP_CD
ORDER BY MBR_KEY, RX_NDC, RX_FILLED_DT, RX_NBR, FILLED_REFILS_NBR, CLM_NBR, CLM_DISP_CD) AS CHECKING FROM RX_IN WHERE CLM_DISP_CD='RVRSL' ) RX2
ON RX1.MBR_KEY= RX2.MBR_KEY AND RX1.RX_NDC = RX2.RX_NDC AND RX1.RX_FILLED_DT=RX2.RX_FILLED_DT AND RX1.RX_NBR=RX2.RX_NBR AND RX1.FILLED_REFILS_NBR=RX2.FILLED_REFILS_NBR
AND RX1.CLM_NBR=RX2.CLM_NBR AND RX1.CHECKING=RX2.CHECKING
)