调优过程
原始SQL如下:
SELECTDISTINCTCASE
WHEN REGEXP_LIKE(B.REGISTERORGID, .XM) THEN
SUBSTR(B.REGISTERORGID,
1,
INSTR(B.REGISTERORGID, .XM, 1) - 1)
ELSE
B.REGISTERORGID
END,
B.SERVNUMBER,
C.RECOPID,
C.RECDATE,
B.SUBSID
FROM TBCS.SUBSCRIBER PARTITION(SUBSCRIBER_724) B,
TBCS.RECEPTION PARTITION(RECEPTION_724_202202) C
WHERE B.NETTYPE = GSM
AND B.ACTIVE = 1
AND B.STATUS = US10
AND B.CREATEDATE > TO_DATE(20220201, YYYYMMDD)
AND B.REGISTERORGID LIKEHB.JM.03.%
AND C.SERVNUMBER = B.SERVNUMBER
AND C.RECDATE > TO_DATE(20220201, YYYYMMDD)
AND C.RECDEFID = Install
AND B.SUBSID NOTIN
(SELECT A.SUBSID
FROM TBCS.SUBS_PRODUCT PARTITION(SUBS_PRODUCT_724) A
WHERE A.PRODID LIKEG238354%
AND A.APPLYDATE > TO_DATE(20220201, YYYYMMDD)
UNIONALL
SELECT A.SUBSID
FROM TBCS.SUBS_PRODUCT PARTITION(SUBS_PRODUCT_724) A
WHERE A.PRODID = MP9990103000300
AND A.APPLYDATE > TO_DATE(20220201, YYYYMMDD)
UNIONALL
SELECT/*+ index(a IDX_SUBS_PRODUCT_PRODID) */
A.SUBSID
FROM TBCS.SUBS_PRODUCT PARTITION(SUBS_PRODUCT_724) A
WHERE A.PRODID IN (SELECT D.PRODID
FROM TBCS.PRODUCT D
WHERE D.PRODNAME LIKEXX%XXX%
OR D.PRODNAME LIKEXX%XXX%
OR D.PRODNAME LIKEXX%XXX%%
OR D.PRODNAME LIKEXX%XXX%%
OR D.PRODNAME LIKE%XX%
OR D.PRODNAME LIKE%XX%)
AND A.APPLYDATE > TO_DATE(20220201, YYYYMMDD))
ORDERBYCASE
WHEN REGEXP_LIKE(B.REGISTERORGID, .XM) THEN
SUBSTR(B.REGISTERORGID, 1, INSTR(B.REGISTERORGID, .XM, 1) - 1)
ELSE
B.REGISTERORGID
END,
C.RECDATE;
分析总结
子查询展开(Subquery Unnesting)是优化器处理带子查询的目标sql的一种优化手段。
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/129420.html
阅读 1249·2023-01-11 13:20
阅读 1557·2023-01-11 13:20
阅读 1011·2023-01-11 13:20
阅读 1680·2023-01-11 13:20
阅读 3971·2023-01-11 13:20
阅读 2518·2023-01-11 13:20
阅读 1310·2023-01-11 13:20
阅读 3485·2023-01-11 13:20