-
[완료]schedule.distr.newScheduleListPageDataPostgresql / PPAS/Query tuning 2022. 8. 29. 11:48
- 검증계
Successfully run. Total query runtime: 50 secs 759 msec.
TO-BE
Successfully run. Total query runtime: 48 secs 906 msec.- 운영계
총 쿼리 실행시간: 22 secs 75 msec.
TO-BE
총 쿼리 실행시간: 19 secs하기 조건으로 인해 19초 이하로 튜닝 불가.
rownum 3초 min/max 16초 → 위 로우넘과 통계 함수를 제거하면 0.07 초 가 나옵니다
인덱스 생성 스크립트
--INDEX
create index idx_pt_lw_sche_mst_04 on IMCSUSER.PT_LW_SCHE_MST (UPDATE_ID);
create index idx_pt_lw_sche_mst_05 on IMCSUSER.PT_LW_SCHE_MST (update_date);create index idx_pt_lw_sche_asset_03 on IMCSUSER.PT_LW_SCHE_ASSET (SCREEN_TYPE);
create index idx_pt_lw_sche_asset_04 on IMCSUSER.PT_LW_SCHE_ASSET (svc_end_date);data 를 access 하여 group by 후 case 문 처리하면서 발생 한 비용이 제일 크며, index scan 같은 경우 파티션 테이블에 키 조건 자체가 없어 pruning 처리가 안되 Index Full scan 되었습니다.
원본 쿼리
SELECT
/schedule.distr.newScheduleListPageData/
RNUM,
TOTAL_CNT,
COALESCE(NULLIF(SCHEDULE_ID, ''), '-') SCHEDULE_ID,
COALESCE(NULLIF(SCHEDULE_TYPE, ''), '-') SCHEDULE_TYPE,
COALESCE(NULLIF(SCHEDULE_DETAIL, ''), '-') SCHEDULE_DETAIL,
COALESCE(NULLIF(CONTENT_TYPE, ''), '-') CONTENT_TYPE,
COALESCE(NULLIF(SERIES_YN, ''), '일반') SERIES_YN,
COALESCE(NULLIF(SEQ_NO, ''), '0') SEQ_NO,
COALESCE(ORDER_NO, '0') ORDER_NO,
COALESCE(NULLIF(VIDEO_TYPE, ''), '-') VIDEO_TYPE,
RTRIM(COALESCE(NULLIF(UHD_YN, ''), '-'), ',') UHD_YN,
SCREEN_TYPE_GB,
COALESCE(NULLIF(CONTENTS_NAME, ''), '-') CONTENTS_NAME,
COALESCE(NULLIF(SERIES_ID_IMCS, ''), '-') SERIES_ID_IMCS,
COALESCE(NULLIF(SERIES_IMCS_NAME, ''), '-') SERIES_IMCS_NAME,
COALESCE(NULLIF(SERIES_NO, ''), '-') SERIES_NO,
COALESCE(NULLIF(SCREEN_TYPE, ''), '-') SCREEN_TYPE,
CASE
CP_ID
WHEN '0' THEN R_CP_ID
WHEN '' THEN R_CP_ID
ELSE CP_ID
END CP_ID,
CASE
WHEN COALESCE(NULLIF(SVC_START_DATE, ''), '-') <> '-'
AND SVC_START_DATE <> '0' THEN TO_CHAR(
TO_DATE(SVC_START_DATE, 'YYYYMMDD'),
'YYYY-MM-DD'
)
ELSE '-'
END SVC_START_DATE,
CASE
WHEN COALESCE(NULLIF(SVC_END_DATE, ''), '-') <> '-'
AND SVC_END_DATE <> '0' THEN TO_CHAR(TO_DATE(SVC_END_DATE, 'YYYYMMDD'), 'YYYY-MM-DD')
ELSE '-'
END SVC_END_DATE,
CASE
WHEN COALESCE(NULLIF(UPDATE_DATE, ''), '-') <> '-'
AND UPDATE_DATE <> '0' THEN TO_CHAR(
TO_TIMESTAMP(UPDATE_DATE, 'YYYYMMDDHH24MISS'),
'YYYY-MM-DD HH24:MI:SS'
)
ELSE '-'
END UPDATE_DATE,
COALESCE(NULLIF(STATUS, ''), '-') STATUS,
COALESCE(NULLIF(PROCESS_STATUS, ''), '-') PROCESS_STATUS,
NSCREEN_YN,
COALESCE(ALBUM_ID, '') ALBUM_ID,
COALESCE(NULLIF(STATUS_MECS_META, ''), 'F') STATUS_MECS_META,
COALESCE(NULLIF(STATUS_INGEST_VIDEO, ''), 'F') STATUS_INGEST_VIDEO,
CUESHEET_ITEM_TYPE,
OMNIV_TYPE,
COALESCE(GENRE_LARGE, '') AS GENRE_LARGE_CD,
COALESCE(GENRE_MID, '') AS GENRE_MID_CD,
COALESCE(GENRE_SMALL, '') AS GENRE_SMALL_CD,
UPDATE_ID,
CP_NAME,
EXCEPT_YN
FROM(
SELECT
-- ROW_NUMBER() OVER (ORDER BY UPDATE_DATE DESC NULLS LAST, SCHEDULE_ID DESC, CASE SUBSTR(SEQ_NO, 1, 1) WHEN 'M' THEN 1 WHEN 'P' THEN 2 WHEN 'A' THEN 3 ELSE 4 END, SEQ_NO DESC, MIN(SCREEN_TYPE) ) RNUM,
ROW_NUMBER() OVER (
ORDER BY
UPDATE_DATE DESC NULLS LAST,
SCHEDULE_ID DESC,
DECODE(
SUBSTR(SEQ_NO, 1, 1),
'M',
1,
'P',
2,
'A',
3,
4
),
SEQ_NO DESC,
MIN(SCREEN_TYPE)
) RNUM,
-- ROW_NUMBER() OVER (ORDER BY UPDATE_DATE DESC NULLS LAST ) RNUM,
SUM (1) OVER () AS TOTAL_CNT,
SCHEDULE_ID,
SCHEDULE_TYPE,
SCHEDULE_DETAIL,
CONTENT_TYPE,
SERIES_YN,
SEQ_NO,
ORDER_NO,
VIDEO_TYPE,
CASE
MAX(UHD_YN) || MAX(HDR_YN)
WHEN 'YN' THEN 'UHD'
WHEN 'NY' THEN 'HDR'
ELSE (
CASE
MAX(HD_YN)
WHEN 'Y' THEN 'HD,'
ELSE ''
END || CASE
MAX(SD_YN)
WHEN 'Y' THEN 'SD,'
ELSE ''
END || CASE
MAX(VA_YN)
WHEN 'Y' THEN 'VA,'
ELSE ''
END || CASE
MAX(UA_YN)
WHEN 'Y' THEN 'UA,'
ELSE ''
END || CASE
MAX(MX_YN)
WHEN 'Y' THEN 'MX,'
ELSE ''
END || CASE
MAX(MH_YN)
WHEN 'Y' THEN 'MH,'
ELSE ''
END || CASE
MAX(MP_YN)
WHEN 'Y' THEN 'MP,'
ELSE ''
END || CASE
MAX(MQ_YN)
WHEN 'Y' THEN 'MQ,'
ELSE ''
END || CASE
MAX(MR_YN)
WHEN 'Y' THEN 'MR,'
ELSE ''
END || CASE
MAX(MG_YN)
WHEN 'Y' THEN 'MG,'
ELSE ''
END || CASE
MAX(MI_YN)
WHEN 'Y' THEN 'MI,'
ELSE ''
END || CASE
MAX(MN_YN)
WHEN 'Y' THEN 'MN,'
ELSE ''
END || CASE
MAX(NA_YN)
WHEN 'Y' THEN 'NA,'
ELSE ''
END || CASE
MAX(NF_YN)
WHEN 'Y' THEN 'NF,'
ELSE ''
END
)
END UHD_YN,
CASE
WHEN MAX(UHD_YN) = 'Y'
OR MAX(HDR_YN) = 'Y'
OR MAX(HD_YN) = 'Y'
OR MAX(SD_YN) = 'Y'
OR MAX(VA_YN) = 'Y'
OR MAX(UA_YN) = 'Y' THEN 'I'
ELSE ''
END || CASE
WHEN MAX(MX_YN) = 'Y'
OR MAX(MH_YN) = 'Y'
OR MAX(MP_YN) = 'Y'
OR MAX(MQ_YN) = 'Y'
OR MAX(MR_YN) = 'Y'
OR MAX(MG_YN) = 'Y'
OR MAX(MI_YN) = 'Y'
OR MAX(MN_YN) = 'Y'
OR MAX(NA_YN) = 'Y'
OR MAX(NF_YN) = 'Y' THEN 'N'
ELSE ''
END AS SCREEN_TYPE_GB,
GENRE_LARGE_CD,
GENRE_MID_CD,
GENRE_SMALL_CD,
CONTENTS_NAME,
SERIES_ID_IMCS,
SERIES_IMCS_NAME,
SERIES_NO,
MIN(SCREEN_TYPE) SCREEN_TYPE,
CASE
MIN(SCREEN_TYPE)
WHEN 'I' THEN CASE
MAX(HD_CP_ID)
WHEN '0' THEN CASE
MAX(SD_CP_ID)
WHEN '0' THEN CASE
MAX(VA_CP_ID)
WHEN '0' THEN CASE
MAX(UA_CP_ID)
WHEN '0' THEN CASE
MAX(UHD_CP_ID)
WHEN '0' THEN MAX(HDR_CP_ID)
ELSE MAX(UHD_CP_ID)
END
ELSE MAX(UA_CP_ID)
END
ELSE MAX(VA_CP_ID)
END
ELSE MAX(SD_CP_ID)
END
ELSE MAX(HD_CP_ID)
END
ELSE CASE
MAX(MX_CP_ID)
WHEN '0' THEN CASE
MAX(MH_CP_ID)
WHEN '0' THEN CASE
MAX(MP_CP_ID)
WHEN '0' THEN CASE
MAX(MQ_CP_ID)
WHEN '0' THEN CASE
MAX(MR_CP_ID)
WHEN '0' THEN CASE
MAX(MG_CP_ID)
WHEN '0' THEN CASE
MAX(MI_CP_ID)
WHEN '0' THEN CASE
MAX(MN_CP_ID)
WHEN '0' THEN CASE
MAX(NA_CP_ID)
WHEN '0' THEN MAX(NF_CP_ID)
ELSE MAX(NA_CP_ID)
END
ELSE MAX(MN_CP_ID)
END
ELSE MAX(MI_CP_ID)
END
ELSE MAX(MG_CP_ID)
END
ELSE MAX(MR_CP_ID)
END
ELSE MAX(MQ_CP_ID)
END
ELSE MAX(MP_CP_ID)
END
ELSE MAX(MH_CP_ID)
END
ELSE MAX(MX_CP_ID)
END
END CP_ID,
MAX(R_CP_ID) R_CP_ID,
CASE
MIN(SCREEN_TYPE)
WHEN 'I' THEN CASE
MAX(HD_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(SD_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(VA_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(UA_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(UHD_SVC_START_DATE)
WHEN '0' THEN MAX(HDR_SVC_START_DATE)
ELSE MAX(UHD_SVC_START_DATE)
END
ELSE MAX(UA_SVC_START_DATE)
END
ELSE MAX(VA_SVC_START_DATE)
END
ELSE MAX(SD_SVC_START_DATE)
END
ELSE MAX(HD_SVC_START_DATE)
END
ELSE CASE
MAX(MX_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MH_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MP_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MQ_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MR_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MG_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MI_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MN_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(NA_SVC_START_DATE)
WHEN '0' THEN MAX(NF_SVC_START_DATE)
ELSE MAX(NA_SVC_START_DATE)
END
ELSE MAX(MN_SVC_START_DATE)
END
ELSE MAX(MI_SVC_START_DATE)
END
ELSE MAX(MG_SVC_START_DATE)
END
ELSE MAX(MR_SVC_START_DATE)
ENDㄴ비
ELSE MAX(MQ_SVC_START_DATE)
END
ELSE MAX(MP_SVC_START_DATE)
END
ELSE MAX(MH_SVC_START_DATE)
END
ELSE MAX(MX_SVC_START_DATE)
END
END SVC_START_DATE,
CASE
MIN(SCREEN_TYPE)
WHEN 'I' THEN CASE
MAX(HD_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(SD_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(VA_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(UA_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(UHD_SVC_END_DATE)
WHEN '0' THEN MAX(HDR_SVC_END_DATE)
ELSE MAX(UHD_SVC_END_DATE)
END
ELSE MAX(UA_SVC_END_DATE)
END
ELSE MAX(VA_SVC_END_DATE)
END
ELSE MAX(SD_SVC_END_DATE)
END
ELSE MAX(HD_SVC_END_DATE)
END
ELSE CASE
MAX(MX_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MH_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MP_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MQ_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MR_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MG_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MI_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MN_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(NA_SVC_END_DATE)
WHEN '0' THEN MAX(NF_SVC_END_DATE)
ELSE MAX(NA_SVC_END_DATE)
END
ELSE MAX(MN_SVC_END_DATE)
END
ELSE MAX(MI_SVC_END_DATE)
END
ELSE MAX(MG_SVC_END_DATE)
END
ELSE MAX(MR_SVC_END_DATE)
END
ELSE MAX(MQ_SVC_END_DATE)
END
ELSE MAX(MP_SVC_END_DATE)
END
ELSE MAX(MH_SVC_END_DATE)
END
ELSE MAX(MX_SVC_END_DATE)
END
END SVC_END_DATE,
STATUS,
PROCESS_STATUS,
NSCREEN_YN,
UPDATE_DATE,
ALBUM_ID,
STATUS_MECS_META,
STATUS_INGEST_VIDEO,
UPDATE_ID,
CUESHEET_ITEM_TYPE,
OMNIV_TYPE,
GENRE_LARGE,
GENRE_MID,
GENRE_SMALL,
CP_NAME,
MAX(EXCEPT_YN) AS EXCEPT_YN
FROM(
SELECT
/*+ USE_HASH(INFO,AST) ORDERED */
MST.SCHEDULE_ID,
CASE
MST.SCHEDULE_TYPE
WHEN 'N' THEN '일반'
WHEN 'R' THEN '재배포'
END SCHEDULE_TYPE,
CASE
MST.SCHEDULE_DETAIL_TYPE
WHEN 0 THEN '일반'
WHEN 1 THEN '영상변경'
WHEN 2 THEN '자막변경'
END SCHEDULE_DETAIL,
CASE
COALESCE(NULLIF(MST.CONTENT_TYPE, ''), 'R')
WHEN 'N' THEN '일반'
WHEN 'S' THEN '특수'
WHEN 'R' THEN '재배포'
END CONTENT_TYPE,
CASE
MST.SERIES_YN
WHEN 'Y' THEN '시리즈'
ELSE '단편'
END SERIES_YN,
CASE
COALESCE(NULLIF(DTL.VIDEO_TYPE, ''), 'M')
WHEN 'M' THEN '본편'
WHEN 'P' THEN '예고편'
WHEN 'A' THEN '부가영상'
END VIDEO_TYPE,
DTL.SEQ_NO,
DTL.ORDER_NO,
MST.GENRE_LARGE_CD,
MST.GENRE_MID_CD,
MST.GENRE_SMALL_CD,
DTL.CONTENTS_NAME,
MST.SERIES_ID_IMCS,
MST.SERIES_IMCS_NAME,
DTL.SERIES_NO,
AST.SCREEN_TYPE,
AST.HD_YN,
AST.SD_YN,
CASE
WHEN AST.SCREEN_TYPE = 'I' THEN SUBSTR(
AST.ASSET_GROUP,
1,
1
)
ELSE 'N'
END AS VA_YN,
CASE
WHEN AST.SCREEN_TYPE = 'I' THEN SUBSTR(
AST.ASSET_GROUP,
2,
1
)
ELSE 'N'
END AS UA_YN,
AST.MX_YN,
AST.MH_YN,
AST.MP_YN,
AST.MQ_YN,
AST.MR_YN,
CASE
WHEN AST.SCREEN_TYPE = 'N' THEN SUBSTR(
AST.ASSET_GROUP,
1,
1
)
ELSE 'N'
END AS MG_YN,
CASE
WHEN AST.SCREEN_TYPE = 'N' THEN SUBSTR(
AST.ASSET_GROUP,
2,
1
)
ELSE 'N'
END AS MI_YN,
CASE
WHEN AST.SCREEN_TYPE = 'N' THEN SUBSTR(
AST.ASSET_GROUP,
3,
1
)
ELSE 'N'
END AS MN_YN,
CASE
WHEN AST.SCREEN_TYPE = 'N' THEN SUBSTR(
AST.ASSET_GROUP,
4,
1
)
ELSE 'N'
END AS NA_YN,
CASE
WHEN AST.SCREEN_TYPE = 'N' THEN SUBSTR(
AST.ASSET_GROUP,
5,
1
)
ELSE 'N'
END AS NF_YN,
AST.UHD_YN,
AST.HDR_YN,
CASE
WHEN HD_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END HD_CP_ID,
CASE
WHEN SD_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END SD_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END VA_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END UA_CP_ID,
CASE
WHEN UHD_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END UHD_CP_ID,
CASE
WHEN HDR_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END HDR_CP_ID,
CASE
WHEN MX_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END MX_CP_ID,
CASE
WHEN MH_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END MH_CP_ID,
CASE
WHEN MP_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END MP_CP_ID,
CASE
WHEN MQ_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END MQ_CP_ID,
CASE
WHEN MR_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END MR_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END MG_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END MI_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
3,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END MN_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
4,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END NA_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
5,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END NF_CP_ID,
CASE
WHEN NULLIF(HD_YN, '') IS NULL
AND NULLIF(SD_YN, '') IS NULL
AND AST.SCREEN_TYPE = 'I'
AND NULLIF(
SUBSTR(
AST.ASSET_GROUP,
1,
1
),
''
) IS NULL
AND AST.SCREEN_TYPE = 'I'
AND NULLIF(SUBSTR(AST.ASSET_GROUP, 2, 1), '') IS NULL
AND NULLIF(UHD_YN, '') IS NULL
AND NULLIF(HDR_YN, '') IS NULL
AND NULLIF(MX_YN, '') IS NULL
AND NULLIF(MH_YN, '') IS NULL
AND NULLIF(MP_YN, '') IS NULL
AND NULLIF(MQ_YN, '') IS NULL
AND MR_YN IS NULL
AND AST.SCREEN_TYPE = 'N'
AND NULLIF(
SUBSTR(
AST.ASSET_GROUP,
1,
1
),
''
) IS NULL
AND AST.SCREEN_TYPE = 'N'
AND NULLIF(SUBSTR(AST.ASSET_GROUP, 2, 1), '') IS NULL
AND AST.SCREEN_TYPE = 'N'
AND NULLIF(
SUBSTR(
AST.ASSET_GROUP,
3,
1
),
''
) IS NULL
AND AST.SCREEN_TYPE = 'N'
AND NULLIF(SUBSTR(AST.ASSET_GROUP, 4, 1), '') IS NULL
AND AST.SCREEN_TYPE = 'N'
AND NULLIF(
SUBSTR(
AST.ASSET_GROUP,
5,
1
),
''
) IS NULL
AND AST.CP_ID IS NOT NULL THEN AST.CP_ID
END R_CP_ID,
CASE
WHEN HD_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END HD_SVC_START_DATE,
CASE
WHEN SD_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END SD_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END VA_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END UA_SVC_START_DATE,
CASE
WHEN UHD_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END UHD_SVC_START_DATE,
CASE
WHEN HDR_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END HDR_SVC_START_DATE,
CASE
WHEN MX_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END MX_SVC_START_DATE,
CASE
WHEN MH_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END MH_SVC_START_DATE,
CASE
WHEN MP_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END MP_SVC_START_DATE,
CASE
WHEN MQ_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END MQ_SVC_START_DATE,
CASE
WHEN MR_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END MR_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END MG_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END MI_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
3,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END MN_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
4,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END NA_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
5,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END NF_SVC_START_DATE,
CASE
WHEN HD_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END HD_SVC_END_DATE,
CASE
WHEN SD_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END SD_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END VA_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END UA_SVC_END_DATE,
CASE
WHEN UHD_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END UHD_SVC_END_DATE,
CASE
WHEN HDR_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END HDR_SVC_END_DATE,
CASE
WHEN MX_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END MX_SVC_END_DATE,
CASE
WHEN MH_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END MH_SVC_END_DATE,
CASE
WHEN MP_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END MP_SVC_END_DATE,
CASE
WHEN MQ_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END MQ_SVC_END_DATE,
CASE
WHEN MR_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END MR_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END MG_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END MI_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
3,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END MN_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
4,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END NA_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
5,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END NF_SVC_END_DATE,
AST.SVC_START_DATE,
AST.SVC_END_DATE,
MST.UPDATE_DATE,
COALESCE(
(
SELECT
LU.USER_NAME
FROM
IMCSUSER.PT_LW_USER LU
WHERE
LU.USER_ID = MST.UPDATE_ID --MST.UPDATE_ID index 없음.
),
''
) AS UPDATE_ID,
MST.STATUS,
DTL.PROCESS_STATUS,
DTL.NSCREEN_YN,
DTL.ALBUM_ID,
INFO.STATUS_MECS_META,
INFO.STATUS_INGEST_VIDEO,
DTL.CUESHEET_ITEM_TYPE,
DTL.OMNIV_TYPE,
MST.GENRE_LARGE,
MST.GENRE_MID,
MST.GENRE_SMALL,
AST.CP_NAME,
AST.EXCEPT_YN
FROM
IMCSUSER.PT_LW_SCHE_MST MST
INNER JOIN IMCSUSER.PT_LW_SCHE_DTL DTL ON MST.SCHEDULE_ID = DTL.SCHEDULE_ID
INNER JOIN IMCSUSER.PT_LW_SCHE_ASSET AST ON MST.SCHEDULE_ID = AST.SCHEDULE_ID
AND DTL.SEQ_NO = AST.SEQ_NO
LEFT JOIN IMCSUSER.PT_LW_SCHE_PROCESS_INFO INFO ON MST.SCHEDULE_ID = INFO.SCHEDULE_ID
AND DTL.SEQ_NO = INFO.SEQ_NO
WHERE
1 = 1
) AA
GROUP BY
SCHEDULE_ID,
SCHEDULE_TYPE,
SCHEDULE_DETAIL,
CONTENT_TYPE,
SERIES_YN,
SEQ_NO,
ORDER_NO,
VIDEO_TYPE,
GENRE_LARGE_CD,
GENRE_MID_CD,
GENRE_SMALL_CD,
CONTENTS_NAME,
SERIES_ID_IMCS,
SERIES_IMCS_NAME,
SERIES_NO,
STATUS,
PROCESS_STATUS,
NSCREEN_YN,
UPDATE_DATE,
UPDATE_ID,
ALBUM_ID,
STATUS_MECS_META,
STATUS_INGEST_VIDEO,
CUESHEET_ITEM_TYPE,
OMNIV_TYPE,
GENRE_LARGE,
GENRE_MID,
GENRE_SMALL,
CP_NAME
) A
FETCH FIRST
100 ROWS ONLY- 튜닝 쿼리 ( with 문 2개를 만들어 rownum 과 case min/max 값을 따로 구하여 select 처리 하였으나 속도 개선이 안됨 )
set work_mem=300000;
WITH IMSI AS (
SELECT
MST.SCHEDULE_ID,
CASE
MST.SCHEDULE_TYPE
WHEN 'N' THEN '일반'
WHEN 'R' THEN '재배포'
END SCHEDULE_TYPE,
CASE
MST.SCHEDULE_DETAIL_TYPE
WHEN 0 THEN '일반'
WHEN 1 THEN '영상변경'
WHEN 2 THEN '자막변경'
END SCHEDULE_DETAIL,
CASE
COALESCE(NULLIF(MST.CONTENT_TYPE, ''), 'R')
WHEN 'N' THEN '일반'
WHEN 'S' THEN '특수'
WHEN 'R' THEN '재배포'
END CONTENT_TYPE,
CASE
MST.SERIES_YN
WHEN 'Y' THEN '시리즈'
ELSE '단편'
END SERIES_YN,
CASE
COALESCE(NULLIF(DTL.VIDEO_TYPE, ''), 'M')
WHEN 'M' THEN '본편'
WHEN 'P' THEN '예고편'
WHEN 'A' THEN '부가영상'
END VIDEO_TYPE,
DTL.SEQ_NO,
DTL.ORDER_NO,
MST.GENRE_LARGE_CD,
MST.GENRE_MID_CD,
MST.GENRE_SMALL_CD,
DTL.CONTENTS_NAME,
MST.SERIES_ID_IMCS,
MST.SERIES_IMCS_NAME,
DTL.SERIES_NO,
AST.SCREEN_TYPE,
AST.HD_YN,
AST.SD_YN,
CASE
WHEN AST.SCREEN_TYPE = 'I' THEN SUBSTR(
AST.ASSET_GROUP,
1,
1
)
ELSE 'N'
END AS VA_YN,
CASE
WHEN AST.SCREEN_TYPE = 'I' THEN SUBSTR(
AST.ASSET_GROUP,
2,
1
)
ELSE 'N'
END AS UA_YN,
AST.MX_YN,
AST.MH_YN,
AST.MP_YN,
AST.MQ_YN,
AST.MR_YN,
CASE
WHEN AST.SCREEN_TYPE = 'N' THEN SUBSTR(
AST.ASSET_GROUP,
1,
1
)
ELSE 'N'
END AS MG_YN,
CASE
WHEN AST.SCREEN_TYPE = 'N' THEN SUBSTR(
AST.ASSET_GROUP,
2,
1
)
ELSE 'N'
END AS MI_YN,
CASE
WHEN AST.SCREEN_TYPE = 'N' THEN SUBSTR(
AST.ASSET_GROUP,
3,
1
)
ELSE 'N'
END AS MN_YN,
CASE
WHEN AST.SCREEN_TYPE = 'N' THEN SUBSTR(
AST.ASSET_GROUP,
4,
1
)
ELSE 'N'
END AS NA_YN,
CASE
WHEN AST.SCREEN_TYPE = 'N' THEN SUBSTR(
AST.ASSET_GROUP,
5,
1
)
ELSE 'N'
END AS NF_YN,
AST.UHD_YN,
AST.HDR_YN,
CASE
WHEN HD_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END HD_CP_ID,
CASE
WHEN SD_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END SD_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END VA_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END UA_CP_ID,
CASE
WHEN UHD_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END UHD_CP_ID,
CASE
WHEN HDR_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END HDR_CP_ID,
CASE
WHEN MX_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END MX_CP_ID,
CASE
WHEN MH_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END MH_CP_ID,
CASE
WHEN MP_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END MP_CP_ID,
CASE
WHEN MQ_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END MQ_CP_ID,
CASE
WHEN MR_YN = 'Y' THEN AST.CP_ID
ELSE '0'
END MR_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END MG_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END MI_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
3,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END MN_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
4,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END NA_CP_ID,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
5,
1
) = 'Y' THEN AST.CP_ID
ELSE '0'
END NF_CP_ID,
CASE
WHEN NULLIF(HD_YN, '') IS NULL
AND NULLIF(SD_YN, '') IS NULL
AND AST.SCREEN_TYPE = 'I'
AND NULLIF(
SUBSTR(
AST.ASSET_GROUP,
1,
1
),
''
) IS NULL
AND AST.SCREEN_TYPE = 'I'
AND NULLIF(SUBSTR(AST.ASSET_GROUP, 2, 1), '') IS NULL
AND NULLIF(UHD_YN, '') IS NULL
AND NULLIF(HDR_YN, '') IS NULL
AND NULLIF(MX_YN, '') IS NULL
AND NULLIF(MH_YN, '') IS NULL
AND NULLIF(MP_YN, '') IS NULL
AND NULLIF(MQ_YN, '') IS NULL
AND MR_YN IS NULL
AND AST.SCREEN_TYPE = 'N'
AND NULLIF(
SUBSTR(
AST.ASSET_GROUP,
1,
1
),
''
) IS NULL
AND AST.SCREEN_TYPE = 'N'
AND NULLIF(SUBSTR(AST.ASSET_GROUP, 2, 1), '') IS NULL
AND AST.SCREEN_TYPE = 'N'
AND NULLIF(
SUBSTR(
AST.ASSET_GROUP,
3,
1
),
''
) IS NULL
AND AST.SCREEN_TYPE = 'N'
AND NULLIF(SUBSTR(AST.ASSET_GROUP, 4, 1), '') IS NULL
AND AST.SCREEN_TYPE = 'N'
AND NULLIF(
SUBSTR(
AST.ASSET_GROUP,
5,
1
),
''
) IS NULL
AND AST.CP_ID IS NOT NULL THEN AST.CP_ID
END R_CP_ID,
CASE
WHEN HD_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END HD_SVC_START_DATE,
CASE
WHEN SD_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END SD_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END VA_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END UA_SVC_START_DATE,
CASE
WHEN UHD_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END UHD_SVC_START_DATE,
CASE
WHEN HDR_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END HDR_SVC_START_DATE,
CASE
WHEN MX_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END MX_SVC_START_DATE,
CASE
WHEN MH_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END MH_SVC_START_DATE,
CASE
WHEN MP_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END MP_SVC_START_DATE,
CASE
WHEN MQ_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END MQ_SVC_START_DATE,
CASE
WHEN MR_YN = 'Y' THEN SVC_START_DATE
ELSE '0'
END MR_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END MG_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END MI_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
3,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END MN_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
4,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END NA_SVC_START_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
5,
1
) = 'Y' THEN SVC_START_DATE
ELSE '0'
END NF_SVC_START_DATE,
CASE
WHEN HD_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END HD_SVC_END_DATE,
CASE
WHEN SD_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END SD_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END VA_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'I'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END UA_SVC_END_DATE,
CASE
WHEN UHD_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END UHD_SVC_END_DATE,
CASE
WHEN HDR_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END HDR_SVC_END_DATE,
CASE
WHEN MX_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END MX_SVC_END_DATE,
CASE
WHEN MH_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END MH_SVC_END_DATE,
CASE
WHEN MP_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END MP_SVC_END_DATE,
CASE
WHEN MQ_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END MQ_SVC_END_DATE,
CASE
WHEN MR_YN = 'Y' THEN SVC_END_DATE
ELSE '0'
END MR_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
1,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END MG_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
2,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END MI_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
3,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END MN_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
4,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END NA_SVC_END_DATE,
CASE
WHEN AST.SCREEN_TYPE = 'N'
AND SUBSTR(
AST.ASSET_GROUP,
5,
1
) = 'Y' THEN SVC_END_DATE
ELSE '0'
END NF_SVC_END_DATE,
AST.SVC_START_DATE,
AST.SVC_END_DATE,
MST.UPDATE_DATE,
COALESCE(
(
SELECT
LU.USER_NAME
FROM
IMCSUSER.PT_LW_USER LU
WHERE
LU.USER_ID = MST.UPDATE_ID --MST.UPDATE_ID index 없음.
),
''
) AS UPDATE_ID,
MST.STATUS,
DTL.PROCESS_STATUS,
DTL.NSCREEN_YN,
DTL.ALBUM_ID,
INFO.STATUS_MECS_META,
INFO.STATUS_INGEST_VIDEO,
DTL.CUESHEET_ITEM_TYPE,
DTL.OMNIV_TYPE,
MST.GENRE_LARGE,
MST.GENRE_MID,
MST.GENRE_SMALL,
AST.CP_NAME,
AST.EXCEPT_YN
FROM
IMCSUSER.PT_LW_SCHE_MST MST
INNER JOIN IMCSUSER.PT_LW_SCHE_DTL DTL ON MST.SCHEDULE_ID = DTL.SCHEDULE_ID
INNER JOIN IMCSUSER.PT_LW_SCHE_ASSET AST ON MST.SCHEDULE_ID = AST.SCHEDULE_ID
AND DTL.SEQ_NO = AST.SEQ_NO
LEFT JOIN IMCSUSER.PT_LW_SCHE_PROCESS_INFO INFO ON MST.SCHEDULE_ID = INFO.SCHEDULE_ID
AND DTL.SEQ_NO = INFO.SEQ_NO
WHERE
1 = 1
), IMSI2 AS (
SELECT
-- ROW_NUMBER() OVER (ORDER BY UPDATE_DATE DESC NULLS LAST, SCHEDULE_ID DESC, CASE SUBSTR(SEQ_NO, 1, 1) WHEN 'M' THEN 1 WHEN 'P' THEN 2 WHEN 'A' THEN 3 ELSE 4 END, SEQ_NO DESC, MIN(SCREEN_TYPE) ) RNUM,
ROW_NUMBER() OVER (
ORDER BY
UPDATE_DATE DESC NULLS LAST,
SCHEDULE_ID DESC,
DECODE(
SUBSTR(SEQ_NO, 1, 1),
'M',
1,
'P',
2,
'A',
3,
4
),
SEQ_NO DESC,
MIN(SCREEN_TYPE)
) RNUM,
-- ROW_NUMBER() OVER (ORDER BY UPDATE_DATE DESC NULLS LAST ) RNUM,
SUM (1) OVER () AS TOTAL_CNT,
SCHEDULE_ID,
SCHEDULE_TYPE,
SCHEDULE_DETAIL,
CONTENT_TYPE,
SERIES_YN,
SEQ_NO,
ORDER_NO,
VIDEO_TYPE,
CASE
MAX(UHD_YN) || MAX(HDR_YN)
WHEN 'YN' THEN 'UHD'
WHEN 'NY' THEN 'HDR'
ELSE (
CASE
MAX(HD_YN)
WHEN 'Y' THEN 'HD,'
ELSE ''
END || CASE
MAX(SD_YN)
WHEN 'Y' THEN 'SD,'
ELSE ''
END || CASE
MAX(VA_YN)
WHEN 'Y' THEN 'VA,'
ELSE ''
END || CASE
MAX(UA_YN)
WHEN 'Y' THEN 'UA,'
ELSE ''
END || CASE
MAX(MX_YN)
WHEN 'Y' THEN 'MX,'
ELSE ''
END || CASE
MAX(MH_YN)
WHEN 'Y' THEN 'MH,'
ELSE ''
END || CASE
MAX(MP_YN)
WHEN 'Y' THEN 'MP,'
ELSE ''
END || CASE
MAX(MQ_YN)
WHEN 'Y' THEN 'MQ,'
ELSE ''
END || CASE
MAX(MR_YN)
WHEN 'Y' THEN 'MR,'
ELSE ''
END || CASE
MAX(MG_YN)
WHEN 'Y' THEN 'MG,'
ELSE ''
END || CASE
MAX(MI_YN)
WHEN 'Y' THEN 'MI,'
ELSE ''
END || CASE
MAX(MN_YN)
WHEN 'Y' THEN 'MN,'
ELSE ''
END || CASE
MAX(NA_YN)
WHEN 'Y' THEN 'NA,'
ELSE ''
END || CASE
MAX(NF_YN)
WHEN 'Y' THEN 'NF,'
ELSE ''
END
)
END UHD_YN,
CASE
WHEN MAX(UHD_YN) = 'Y'
OR MAX(HDR_YN) = 'Y'
OR MAX(HD_YN) = 'Y'
OR MAX(SD_YN) = 'Y'
OR MAX(VA_YN) = 'Y'
OR MAX(UA_YN) = 'Y' THEN 'I'
ELSE ''
END || CASE
WHEN MAX(MX_YN) = 'Y'
OR MAX(MH_YN) = 'Y'
OR MAX(MP_YN) = 'Y'
OR MAX(MQ_YN) = 'Y'
OR MAX(MR_YN) = 'Y'
OR MAX(MG_YN) = 'Y'
OR MAX(MI_YN) = 'Y'
OR MAX(MN_YN) = 'Y'
OR MAX(NA_YN) = 'Y'
OR MAX(NF_YN) = 'Y' THEN 'N'
ELSE ''
END AS SCREEN_TYPE_GB,
GENRE_LARGE_CD,
GENRE_MID_CD,
GENRE_SMALL_CD,
CONTENTS_NAME,
SERIES_ID_IMCS,
SERIES_IMCS_NAME,
SERIES_NO,
MIN(SCREEN_TYPE) SCREEN_TYPE,
CASE
MIN(SCREEN_TYPE)
WHEN 'I' THEN CASE
MAX(HD_CP_ID)
WHEN '0' THEN CASE
MAX(SD_CP_ID)
WHEN '0' THEN CASE
MAX(VA_CP_ID)
WHEN '0' THEN CASE
MAX(UA_CP_ID)
WHEN '0' THEN CASE
MAX(UHD_CP_ID)
WHEN '0' THEN MAX(HDR_CP_ID)
ELSE MAX(UHD_CP_ID)
END
ELSE MAX(UA_CP_ID)
END
ELSE MAX(VA_CP_ID)
END
ELSE MAX(SD_CP_ID)
END
ELSE MAX(HD_CP_ID)
END
ELSE CASE
MAX(MX_CP_ID)
WHEN '0' THEN CASE
MAX(MH_CP_ID)
WHEN '0' THEN CASE
MAX(MP_CP_ID)
WHEN '0' THEN CASE
MAX(MQ_CP_ID)
WHEN '0' THEN CASE
MAX(MR_CP_ID)
WHEN '0' THEN CASE
MAX(MG_CP_ID)
WHEN '0' THEN CASE
MAX(MI_CP_ID)
WHEN '0' THEN CASE
MAX(MN_CP_ID)
WHEN '0' THEN CASE
MAX(NA_CP_ID)
WHEN '0' THEN MAX(NF_CP_ID)
ELSE MAX(NA_CP_ID)
END
ELSE MAX(MN_CP_ID)
END
ELSE MAX(MI_CP_ID)
END
ELSE MAX(MG_CP_ID)
END
ELSE MAX(MR_CP_ID)
END
ELSE MAX(MQ_CP_ID)
END
ELSE MAX(MP_CP_ID)
END
ELSE MAX(MH_CP_ID)
END
ELSE MAX(MX_CP_ID)
END
END CP_ID,
MAX(R_CP_ID) R_CP_ID,
CASE
MIN(SCREEN_TYPE)
WHEN 'I' THEN CASE
MAX(HD_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(SD_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(VA_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(UA_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(UHD_SVC_START_DATE)
WHEN '0' THEN MAX(HDR_SVC_START_DATE)
ELSE MAX(UHD_SVC_START_DATE)
END
ELSE MAX(UA_SVC_START_DATE)
END
ELSE MAX(VA_SVC_START_DATE)
END
ELSE MAX(SD_SVC_START_DATE)
END
ELSE MAX(HD_SVC_START_DATE)
END
ELSE CASE
MAX(MX_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MH_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MP_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MQ_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MR_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MG_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MI_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(MN_SVC_START_DATE)
WHEN '0' THEN CASE
MAX(NA_SVC_START_DATE)
WHEN '0' THEN MAX(NF_SVC_START_DATE)
ELSE MAX(NA_SVC_START_DATE)
END
ELSE MAX(MN_SVC_START_DATE)
END
ELSE MAX(MI_SVC_START_DATE)
END
ELSE MAX(MG_SVC_START_DATE)
END
ELSE MAX(MR_SVC_START_DATE)
END
ELSE MAX(MQ_SVC_START_DATE)
END
ELSE MAX(MP_SVC_START_DATE)
END
ELSE MAX(MH_SVC_START_DATE)
END
ELSE MAX(MX_SVC_START_DATE)
END
END SVC_START_DATE,
CASE
MIN(SCREEN_TYPE)
WHEN 'I' THEN CASE
MAX(HD_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(SD_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(VA_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(UA_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(UHD_SVC_END_DATE)
WHEN '0' THEN MAX(HDR_SVC_END_DATE)
ELSE MAX(UHD_SVC_END_DATE)
END
ELSE MAX(UA_SVC_END_DATE)
END
ELSE MAX(VA_SVC_END_DATE)
END
ELSE MAX(SD_SVC_END_DATE)
END
ELSE MAX(HD_SVC_END_DATE)
END
ELSE CASE
MAX(MX_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MH_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MP_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MQ_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MR_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MG_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MI_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(MN_SVC_END_DATE)
WHEN '0' THEN CASE
MAX(NA_SVC_END_DATE)
WHEN '0' THEN MAX(NF_SVC_END_DATE)
ELSE MAX(NA_SVC_END_DATE)
END
ELSE MAX(MN_SVC_END_DATE)
END
ELSE MAX(MI_SVC_END_DATE)
END
ELSE MAX(MG_SVC_END_DATE)
END
ELSE MAX(MR_SVC_END_DATE)
END
ELSE MAX(MQ_SVC_END_DATE)
END
ELSE MAX(MP_SVC_END_DATE)
END
ELSE MAX(MH_SVC_END_DATE)
END
ELSE MAX(MX_SVC_END_DATE)
END
END SVC_END_DATE,
STATUS,
PROCESS_STATUS,
NSCREEN_YN,
UPDATE_DATE,
ALBUM_ID,
STATUS_MECS_META,
STATUS_INGEST_VIDEO,
UPDATE_ID,
CUESHEET_ITEM_TYPE,
OMNIV_TYPE,
GENRE_LARGE,
GENRE_MID,
GENRE_SMALL,
CP_NAME,
MAX(EXCEPT_YN) AS EXCEPT_YN
FROM IMSI
GROUP BY
SCHEDULE_ID,
SCHEDULE_TYPE,
SCHEDULE_DETAIL,
CONTENT_TYPE,
SERIES_YN,
SEQ_NO,
ORDER_NO,
VIDEO_TYPE,
GENRE_LARGE_CD,
GENRE_MID_CD,
GENRE_SMALL_CD,
CONTENTS_NAME,
SERIES_ID_IMCS,
SERIES_IMCS_NAME,
SERIES_NO,
STATUS,
PROCESS_STATUS,
NSCREEN_YN,
UPDATE_DATE,
UPDATE_ID,
ALBUM_ID,
STATUS_MECS_META,
STATUS_INGEST_VIDEO,
CUESHEET_ITEM_TYPE,
OMNIV_TYPE,
GENRE_LARGE,
GENRE_MID,
GENRE_SMALL,
CP_NAME
LIMIT 100
)
SELECT
/schedule.distr.newScheduleListPageData/
RNUM,
TOTAL_CNT,
COALESCE(NULLIF(SCHEDULE_ID, ''), '-') SCHEDULE_ID,
COALESCE(NULLIF(SCHEDULE_TYPE, ''), '-') SCHEDULE_TYPE,
COALESCE(NULLIF(SCHEDULE_DETAIL, ''), '-') SCHEDULE_DETAIL,
COALESCE(NULLIF(CONTENT_TYPE, ''), '-') CONTENT_TYPE,
COALESCE(NULLIF(SERIES_YN, ''), '일반') SERIES_YN,
COALESCE(NULLIF(SEQ_NO, ''), '0') SEQ_NO,
COALESCE(ORDER_NO, '0') ORDER_NO,
COALESCE(NULLIF(VIDEO_TYPE, ''), '-') VIDEO_TYPE,
RTRIM(COALESCE(NULLIF(UHD_YN, ''), '-'), ',') UHD_YN,
SCREEN_TYPE_GB,
COALESCE(NULLIF(CONTENTS_NAME, ''), '-') CONTENTS_NAME,
COALESCE(NULLIF(SERIES_ID_IMCS, ''), '-') SERIES_ID_IMCS,
COALESCE(NULLIF(SERIES_IMCS_NAME, ''), '-') SERIES_IMCS_NAME,
COALESCE(NULLIF(SERIES_NO, ''), '-') SERIES_NO,
COALESCE(NULLIF(SCREEN_TYPE, ''), '-') SCREEN_TYPE,
CASE
CP_ID
WHEN '0' THEN R_CP_ID
WHEN '' THEN R_CP_ID
ELSE CP_ID
END CP_ID,
CASE
WHEN COALESCE(NULLIF(SVC_START_DATE, ''), '-') <> '-'
AND SVC_START_DATE <> '0' THEN TO_CHAR(
TO_DATE(SVC_START_DATE, 'YYYYMMDD'),
'YYYY-MM-DD'
)
ELSE '-'
END SVC_START_DATE,
CASE
WHEN COALESCE(NULLIF(SVC_END_DATE, ''), '-') <> '-'
AND SVC_END_DATE <> '0' THEN TO_CHAR(TO_DATE(SVC_END_DATE, 'YYYYMMDD'), 'YYYY-MM-DD')
ELSE '-'
END SVC_END_DATE,
CASE
WHEN COALESCE(NULLIF(UPDATE_DATE, ''), '-') <> '-'
AND UPDATE_DATE <> '0' THEN TO_CHAR(
TO_TIMESTAMP(UPDATE_DATE, 'YYYYMMDDHH24MISS'),
'YYYY-MM-DD HH24:MI:SS'
)
ELSE '-'
END UPDATE_DATE,
COALESCE(NULLIF(STATUS, ''), '-') STATUS,
COALESCE(NULLIF(PROCESS_STATUS, ''), '-') PROCESS_STATUS,
NSCREEN_YN,
COALESCE(ALBUM_ID, '') ALBUM_ID,
COALESCE(NULLIF(STATUS_MECS_META, ''), 'F') STATUS_MECS_META,
COALESCE(NULLIF(STATUS_INGEST_VIDEO, ''), 'F') STATUS_INGEST_VIDEO,
CUESHEET_ITEM_TYPE,
OMNIV_TYPE,
COALESCE(GENRE_LARGE, '') AS GENRE_LARGE_CD,
COALESCE(GENRE_MID, '') AS GENRE_MID_CD,
COALESCE(GENRE_SMALL, '') AS GENRE_SMALL_CD,
UPDATE_ID,
CP_NAME,
EXCEPT_YN
FROM IMSI2'Postgresql / PPAS > Query tuning' 카테고리의 다른 글
[완료] /* content.base.seriesListPageData */ (0) 2022.08.29 [완료]/* abtest.content.base.popupAbtestFormRouteListPageDataSeries */ (0) 2022.08.29 [완료] /* modifySchedule.base.selectContentListBySeriesIdDup */ (2) 2022.08.29 [완료] /* modifySchedule.base.selectContentListBySeriesId */ (0) 2022.08.29 [튜닝불가] /* categoryform.dr.getAlbumSeriesList */ (0) 2022.08.29