사이트에서 많이 배우고 있습니다. 조언 부탁드립니다.
현재 데이터 출력시간이 10초가 넘어 가고 있습니다.
무지해서 어느 곳에서 시간을 잡아먹는지를 못찾고 있습니다.
비효율적인 쿼리 튜닝 부탁드리겠습니다.
SELECT *
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY GUBUN ASC, YMD DESC) AS RN
, GUBUN
, YMD
, SUM(CNT1) AS CNT1
, SUM(CNT2) AS CNT2
, SUM(CNT3) AS CNT3
, SUM(CNT4) AS CNT4
FROM (
SELECT DECODE(TO_CHAR(0), '0'
, DECODE(TO_CHAR(0), '0'
, DECODE(TO_CHAR(0), '0'
, DECODE(TO_CHAR(0), '0'
, T3.BROADGOV
, T3.BASICGOV)
, NVL(T3.SUBGU, T3.DONG))
, T3.DONG)
, T3.DONG) AS GUBUN
, TO_CHAR(T1.REG_DATE, 'YYYY.MM.DD') AS YMD
, CASE WHEN T1.N_JOIN_DEV_CODE = '0001' THEN 1 ELSE NULL END AS CNT1
, CASE WHEN T1.N_JOIN_DEV_CODE = '0002' THEN 1 ELSE NULL END AS CNT2
, CASE WHEN TO_NUMBER(T1.STATUS) = 8 OR TO_NUMBER(T1.STATUS) = 9 THEN 1 ELSE NULL END AS CNT3
, CASE WHEN TO_NUMBER(T1.STATUS) = 2 THEN 1 ELSE NULL END AS CNT4
FROM TB_USER T1
, TB_ADDR T3
, TB_CODE T4
, TB_USER_DETAIL T5
WHERE 1=1
AND T1.ADDRCODE = T3.ADDRCODE
AND T1.GOV_ID = DECODE(T4.CODE_2, '****', T4.CODE_1, T4.CODE_2)
AND LOWER(T4.COL_NM) = 'gov_id'
AND T4.USE_CL = 'Y'
AND T4.CODE_1 <> 'E0SL00'
AND T1.USER_ID = T5.USER_ID
) A
GROUP BY GUBUN, YMD
)
|