-
[ 완료]/*new4dSchedule.distr.new4dScheduleListPageData*/Postgresql / PPAS/Query tuning 2022. 8. 29. 13:25
-- 개선 결과
AS-IS
Total query runtime: 1 secs 969 msec.
TO-BE
Total query runtime: 511 msec.* 분석 내용
-- 해당 쿼리는 4개 쿼리를 inner join 하고 1개 테이블을 Outer Join 해서 가져오는 쿼리로 Outer join 쿼리로 인해 늦어지는 쿼리
-- Outer 대상 imcsuser.PT_LW_SCHE_PROCESS_INFO 테이블 사용하지 않기 때문에 제거.* 원본 쿼리
SELECT /*new4dSchedule.distr.new4dScheduleListPageData*/
TOTAL_CNT ,
RNUM ,
SCHEDULE_ID ,
SEQ_NO ,
CONTENTS_NAME ,
PRESET_CODE ,
PRESET_SEQ_NO ,
CONTENT_VALUE ,
FILE_PATH1 ,
FILE_NAME1 ,
FILE_SIZE1 ,
SAVED_FILE_NAME1 ,
SVC_FILE_NAME1 ,
FILE_PATH2 ,
FILE_NAME2 ,
FILE_SIZE2 ,
SAVED_FILE_NAME2 ,
SVC_FILE_NAME2 ,
FILE_PATH3 ,
FILE_NAME3 ,
FILE_SIZE3 ,
SAVED_FILE_NAME3 ,
SVC_FILE_NAME3 ,
FILE_PATH4 ,
FILE_NAME4 ,
FILE_SIZE4 ,
SAVED_FILE_NAME4 ,
SVC_FILE_NAME4 ,
FILE_PATH5 ,
FILE_NAME5 ,
FILE_SIZE5 ,
SAVED_FILE_NAME5 ,
SVC_FILE_NAME5 ,
TO_CHAR(to_timestamp(AA.INSERT_DATE,'YYYYMMDDhh24miss'), 'YYYY-MM-DD hh24:mi:ss') AS INSERT_DATE,
COALESCE((SELECT USER_NAME FROM imcsuser.PT_LW_USER A WHERE A.USER_ID = AA.INSERT_ID), '') AS INSERT_ID,
TO_CHAR(to_timestamp(AA.UPDATE_DATE,'YYYYMMDDhh24miss'), 'YYYY-MM-DD hh24:mi:ss') AS UPDATE_DATE,
COALESCE((SELECT USER_NAME FROM imcsuser.PT_LW_USER A WHERE A.USER_ID = AA.UPDATE_ID), '') AS UPDATE_ID,
STATUS,
PROCESS_STATUS,
TO_CHAR(TO_DATE(AA.SVC_START_DATE,'YYYYMMDD'), 'YYYY-MM-DD') AS SVC_START_DATE,
TO_CHAR(TO_DATE(AA.SVC_END_DATE,'YYYYMMDD'), 'YYYY-MM-DD') AS SVC_END_DATE,
EXCEPT_YN,
ALBUM_ID
FROM
(
SELECT
COUNT(PFILE.SCHEDULE_ID) OVER() AS TOTAL_CNT ,
ROW_NUMBER() OVER (
ORDER BY PFILE.INSERT_DATE DESC) RNUM ,
PFILE.SCHEDULE_ID ,
PFILE.SEQ_NO ,
PFILE.CONTENTS_NAME ,
PFILE.PRESET_CODE ,
PFILE.PRESET_SEQ_NO ,
PFILE.CONTENT_VALUE ,
PFILE.FILE_PATH1 ,
PFILE.FILE_NAME1 ,
PFILE.FILE_SIZE1 ,
PFILE.SAVED_FILE_NAME1 ,
PFILE.SVC_FILE_NAME1 ,
PFILE.FILE_PATH2 ,
PFILE.FILE_NAME2 ,
PFILE.FILE_SIZE2 ,
PFILE.SAVED_FILE_NAME2 ,
PFILE.SVC_FILE_NAME2 ,
PFILE.FILE_PATH3 ,
PFILE.FILE_NAME3 ,
PFILE.FILE_SIZE3 ,
PFILE.SAVED_FILE_NAME3 ,
PFILE.SVC_FILE_NAME3 ,
PFILE.FILE_PATH4 ,
PFILE.FILE_NAME4 ,
PFILE.FILE_SIZE4 ,
PFILE.SAVED_FILE_NAME4 ,
PFILE.SVC_FILE_NAME4 ,
PFILE.FILE_PATH5 ,
PFILE.FILE_NAME5 ,
PFILE.FILE_SIZE5 ,
PFILE.SAVED_FILE_NAME5 ,
PFILE.SVC_FILE_NAME5 ,
MST.STATUS,
MST.INSERT_DATE ,
MST.INSERT_ID ,
MST.UPDATE_DATE ,
MST.UPDATE_ID,
DTL.PROCESS_STATUS,
AST.SVC_START_DATE,
AST.SVC_END_DATE,
AST.EXCEPT_YN,
DTL.ALBUM_ID
FROM
imcsuser.PT_LW_SCHE_PRESET_FILE PFILE
join imcsuser.PT_LW_SCHE_MST MST on PFILE.SCHEDULE_ID = MST.SCHEDULE_ID
join imcsuser.PT_LW_SCHE_DTL DTL on MST.SCHEDULE_ID = DTL.SCHEDULE_ID
join imcsuser.PT_LW_SCHE_ASSET AST on MST.SCHEDULE_ID = AST.SCHEDULE_ID and DTL.SEQ_NO = AST.SEQ_NO
LEFT OUTER 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
WHERE AA.RNUM BETWEEN 0+1 AND 0 + 50* 튜닝 쿼리
begin;
set work_mem=200000;
SELECT /*new4dSchedule.distr.new4dScheduleListPageData*/
TOTAL_CNT ,
RNUM ,
SCHEDULE_ID ,
SEQ_NO ,
CONTENTS_NAME ,
PRESET_CODE ,
PRESET_SEQ_NO ,
CONTENT_VALUE ,
FILE_PATH1 ,
FILE_NAME1 ,
FILE_SIZE1 ,
SAVED_FILE_NAME1 ,
SVC_FILE_NAME1 ,
FILE_PATH2 ,
FILE_NAME2 ,
FILE_SIZE2 ,
SAVED_FILE_NAME2 ,
SVC_FILE_NAME2 ,
FILE_PATH3 ,
FILE_NAME3 ,
FILE_SIZE3 ,
SAVED_FILE_NAME3 ,
SVC_FILE_NAME3 ,
FILE_PATH4 ,
FILE_NAME4 ,
FILE_SIZE4 ,
SAVED_FILE_NAME4 ,
SVC_FILE_NAME4 ,
FILE_PATH5 ,
FILE_NAME5 ,
FILE_SIZE5 ,
SAVED_FILE_NAME5 ,
SVC_FILE_NAME5 ,
TO_CHAR(to_timestamp(AA.INSERT_DATE,'YYYYMMDDhh24miss'), 'YYYY-MM-DD hh24:mi:ss') AS INSERT_DATE,
COALESCE((SELECT USER_NAME FROM imcsuser.PT_LW_USER A WHERE A.USER_ID = AA.INSERT_ID), '') AS INSERT_ID,
TO_CHAR(to_timestamp(AA.UPDATE_DATE,'YYYYMMDDhh24miss'), 'YYYY-MM-DD hh24:mi:ss') AS UPDATE_DATE,
COALESCE((SELECT USER_NAME FROM imcsuser.PT_LW_USER A WHERE A.USER_ID = AA.UPDATE_ID), '') AS UPDATE_ID,
STATUS,
PROCESS_STATUS,
TO_CHAR(TO_DATE(AA.SVC_START_DATE,'YYYYMMDD'), 'YYYY-MM-DD') AS SVC_START_DATE,
TO_CHAR(TO_DATE(AA.SVC_END_DATE,'YYYYMMDD'), 'YYYY-MM-DD') AS SVC_END_DATE,
EXCEPT_YN,
ALBUM_ID
FROM
(
SELECT
COUNT(PFILE.SCHEDULE_ID) OVER() AS TOTAL_CNT ,
ROW_NUMBER() OVER (
ORDER BY PFILE.INSERT_DATE DESC) RNUM ,
PFILE.SCHEDULE_ID ,
PFILE.SEQ_NO ,
PFILE.CONTENTS_NAME ,
PFILE.PRESET_CODE ,
PFILE.PRESET_SEQ_NO ,
PFILE.CONTENT_VALUE ,
PFILE.FILE_PATH1 ,
PFILE.FILE_NAME1 ,
PFILE.FILE_SIZE1 ,
PFILE.SAVED_FILE_NAME1 ,
PFILE.SVC_FILE_NAME1 ,
PFILE.FILE_PATH2 ,
PFILE.FILE_NAME2 ,
PFILE.FILE_SIZE2 ,
PFILE.SAVED_FILE_NAME2 ,
PFILE.SVC_FILE_NAME2 ,
PFILE.FILE_PATH3 ,
PFILE.FILE_NAME3 ,
PFILE.FILE_SIZE3 ,
PFILE.SAVED_FILE_NAME3 ,
PFILE.SVC_FILE_NAME3 ,
PFILE.FILE_PATH4 ,
PFILE.FILE_NAME4 ,
PFILE.FILE_SIZE4 ,
PFILE.SAVED_FILE_NAME4 ,
PFILE.SVC_FILE_NAME4 ,
PFILE.FILE_PATH5 ,
PFILE.FILE_NAME5 ,
PFILE.FILE_SIZE5 ,
PFILE.SAVED_FILE_NAME5 ,
PFILE.SVC_FILE_NAME5 ,
MST.STATUS,
MST.INSERT_DATE ,
MST.INSERT_ID ,
MST.UPDATE_DATE ,
MST.UPDATE_ID,
DTL.PROCESS_STATUS,
AST.SVC_START_DATE,
AST.SVC_END_DATE,
AST.EXCEPT_YN,
DTL.ALBUM_ID
FROM
imcsuser.PT_LW_SCHE_PRESET_FILE PFILE
join imcsuser.PT_LW_SCHE_MST MST on PFILE.SCHEDULE_ID = MST.SCHEDULE_ID
join imcsuser.PT_LW_SCHE_DTL DTL on MST.SCHEDULE_ID = DTL.SCHEDULE_ID
join imcsuser.PT_LW_SCHE_ASSET AST on MST.SCHEDULE_ID = AST.SCHEDULE_ID and DTL.SEQ_NO = AST.SEQ_NO
WHERE 1=1
)AA
WHERE AA.RNUM BETWEEN 0+1 AND 0 + 50
commit;'Postgresql / PPAS > Query tuning' 카테고리의 다른 글
[완료]/* categoryForm.base.getAlbumNameSearchList */ (0) 2022.08.29 [완료]/*distribute.distr.distributeListStatusPageData*/ (0) 2022.08.29 [완료]/*abtest.categoryForm.base.getAlbumNameInSeriesAlbum*/ (0) 2022.08.29 [완료]/* cuesheet.base.getCueSheetItemDetailForLayer */ (0) 2022.08.29 [완료] /* content.base.seriesListPageData */ (0) 2022.08.29