我有以下查詢需要12小時執行,是否可以優化?表YYYYY
的DRV_START_DATE
是NUMBER
數據類型,因此將輸入值轉換爲to_number
將有所幫助。合併查詢花費超過12小時執行任何優化
MERGE INTO XXXX D USING(
SELECT /*+parallel(a 10)*/
a.BATCH_NUMBER,COUNT(*) AS CALL_COUNT
FROM [email protected]_RAPROD a
WHERE a.DRV_START_DATE BETWEEN TO_CHAR(SYSDATE-7,'YYYYMMDD')
AND TO_CHAR(SYSDATE,'YYYYMMDD')
AND a.TOTAL_TYPE =195
GROUP BY a.BATCH_NUMBER)
ON (D.BATCH_NUMBER=S.BATCH_NUMBER)
WHEN MATCHED THEN
UPDATE SET D.CALL_COUNT=S.CALL_COUNT
WHEN NOT MATCHED THEN
INSERT (D.BATCH_NUMBER,D.CALL_COUNT)
VALUES (S.BATCH_NUMBER,S.CALL_COUNT)
DRV_START_DATE是DATE還是VARCHAR2列? – Ollie
@Ollie:表YYYYY的DRV_START_DATE是「NUMBER」數據類型。我提到 –
所以你做了,我應該學會完全閱讀這篇文章!我很抱歉。 – Ollie