SELECT ... 생략
FROM trd100 a ,
trm100 b ,
trm150 c
WHERE a.acpt_no = b.acpt_no
AND a.acpt_no = c.acpt_no
AND b.styl_cd = 'AC01'
AND a.proc_stus IN ( 'D' , 'E' )
AND a.brof_cd LIKE TRIM( :b0 ) || '%'
AND a.acpt_dt || a.acpt_time < :b1
ORDER BY a.acpt_dt DESC ,
a.acpt_time DESC ;
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.01 0 0 0 0
Fetch 41 0.90 26.17 4718 8666 0 599
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 43 0.90 26.18 4718 8666 0 599
Rows Row Source Operation
---------- ---------------------------------------------------
599 SORT ORDER BY (cr=8666 pr=4718 pw=0 time=26173450 us ...)
599 TABLE ACCESS BY INDEX ROWID TRM100 (cr=8666 pr=4718 ...)
1199 NESTED LOOPS (cr=8067 pr=4141 pw=0 time=33177311 us ...)
599 NESTED LOOPS (cr=6864 pr=3678 pw=0 time=42743190 us ...)
2057 TABLE ACCESS BY INDEX ROWID TRD100 (cr=2143 pr=2050 ...)
2057 INDEX RANGE SCAN IX_TRD100_01 (cr=163 pr=162 ...)
599 TABLE ACCESS BY INDEX ROWID TRM150 (cr=4721 pr=1628 ...)
599 INDEX UNIQUE SCAN PK_TRM150 (cr=4122 pr=1059 ...)
599 INDEX UNIQUE SCAN IX_TRM100_02 (cr=1203 pr=463 ...)
[A] WHERE 조회 조건
AND a.proc_stus IN ( 'D' , 'E' )
AND a.brof_cd LIKE TRIM( :b0 ) || '%'
[B] 인덱스 구성정보
INDEX_NAME COLUMN LIST
------------ ---------------------------------------
ix_trd100_01 brof_cd, proc_stus, acpt_dt, acpt_time
[C] ORDER BY (정렬 기준)
ORDER BY a.acpt_dt DESC,
a.acpt_time DESC
[D] ROWNUM 처리 . 없음.
[E] PLAN 상 OPERATION
599 SORT ORDER BY (cr=8666 pr=4718 pw=0 time=26173450 us ...)
SELECT *
FROM (
SELECT ROWNUM rnum , x.*
FROM ( SELECT /*+ LEADING(A) USE_NL(A B C) INDEX_DESC(A IX_TRD100_01) */
... 생략
FROM trd100 a, trm100 b, trm150 c
WHERE a.acpt_no = b.acpt_no
AND a.acpt_no = c.acpt_no
AND b.styl_cd = 'AC01'
AND a.proc_stus IN ( 'D' , 'E' )
AND a.brof_cd LIKE TRIM( :b0 ) || '%'
AND a.acpt_dt || a.acpt_time < :b1
ORDER BY a.acpt_dt DESC , a.acpt_time DESC
) x
)
WHERE rnum <= :b2 and rnum >= :b3 ;
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 5 0.90 27.90 4672 8665 0 50
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 7 0.90 27.91 4672 8665 0 50
Rows Row Source Operation
---------- ---------------------------------------------------
50 FILTER (cr=8665 pr=4672 pw=0 time=27904482 us)
50 VIEW (cr=8665 pr=4672 pw=0 time=27904479 us ...)
599 COUNT (cr=8665 pr=4672 pw=0 time=27905514 us)
599 VIEW (cr=8665 pr=4672 pw=0 time=27905065 us ...)
599 SORT ORDER BY (cr=8665 pr=4672 pw=0 time=27904910 us ...)
599 TABLE ACCESS BY INDEX ROWID TRM100 (cr=8665 pr=4672 ...)
1199 NESTED LOOPS (cr=8066 pr=4100 pw=0 time=4626814 us ...)
599 NESTED LOOPS (cr=6863 pr=3635 pw=0 time=13468562 us ...)
2057 TABLE ACCESS BY INDEX ROWID TRD100 (cr=2142 pr=1905 ...)
2057 INDEX RANGE SCAN DESCENDING IX_TRD100_01 (cr=163 pr=1 ...)
599 TABLE ACCESS BY INDEX ROWID TRM150 (cr=4721 pr=1730 ...)
599 INDEX UNIQUE SCAN PK_TRM150 (cr=4122 pr=1166 ...)
599 INDEX UNIQUE SCAN IX_TRM100_02 (cr=1203 pr=465 ...)
[A] WHERE 조회 조건
AND a.proc_stus IN ( 'D' , 'E' )
AND a.brof_cd LIKE TRIM( :b0 ) || '%'
[B] 인덱스 구성정보
INDEX_NAME COLUMN LIST
------------- --------------------------------------
ix_trd100_01 brof_cd, proc_stus, acpt_dt, acpt_time
[C] ORDER BY (정렬 기준)
ORDER BY a.acpt_dt DESC,
a.acpt_time DESC
[D] ROWNUM 처리
rnum <= :b2 and rnum >= :b3
[E] PLAN 상 OPERATION
599 COUNT (cr=8665 pr=4672 pw=0 time=27905514 us)
599 VIEW (cr=8665 pr=4672 pw=0 time=27905065 us ...)
599 SORT ORDER BY (cr=8665 pr=4672 pw=0 time=27904910 us ...)
SELECT *
FROM (
SELECT ROWNUM rnum ,
x.*
FROM (
SELECT * FROM ...
ORDER BY a.acpt_dt DESC,
a.acpt_time DESC ---> 문제점.Order By 절과 인덱스 구성순서와 다름
) x
)
WHERE rnum <= :b2 AND rnum >= :b3 ; ---> 문제점.ROWNUM 처리가 부적절
SELECT *
FROM (
SELECT ROWNUM rnum ,
x.*
FROM (
SELECT * FROM ...
ORDER BY a.brof_cd DESC,
a.proc_stus DESC,
a.acpt_dt DESC,
a.acpt_time DESC ---> 개선내용.Order By 절과 인덱스 구성순서와 맞춤
) x
WHERE ROWNUM <= :b2 ---> 개선내용.부분범위 처리가 되도록 ROWNUM 처리 변경
)
WHERE rnum >= :b1 ;
SELECT *
FROM (
SELECT ROWNUM rnum , x.*
FROM (
SELECT /*+ LEADING(A) USE_NL(A B C) INDEX_DESC(A IX_TRD100_01) */
... 생략
FROM trd100 a ,
trm100 b ,
trm150 c
WHERE a.acpt_no = b.acpt_no
AND a.acpt_no = c.acpt_no
AND b.styl_cd = 'AC01'
AND a.proc_stus IN ( 'D' , 'E' )
AND a.brof_cd LIKE TRIM( :b0 ) || '%'
AND a.acpt_dt || a.acpt_time < :b1
ORDER BY a.acpt_dt DESC ,
a.acpt_time DESC
) x
WHERE ROWNUM <= :b2
)
WHERE rnum >= :b3 ;
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.01 0.00 0 0 0 0
Fetch 5 0.97 31.65 4949 8665 0 50
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 7 0.98 31.66 4949 8665 0 50
Rows Row Source Operation
---------- ---------------------------------------------------
50 VIEW (cr=8665 pr=4949 pw=0 time=31655963 us ...)
50 COUNT STOPKEY (cr=8665 pr=4949 pw=0 time=31655952 us)
50 VIEW (cr=8665 pr=4949 pw=0 time=31655949 us ...)
50 SORT ORDER BY STOPKEY (cr=8665 pr=4949 pw=0 time=31655944 us ...)
599 TABLE ACCESS BY INDEX ROWID TRM100 (cr=8665 pr=4949 ...)
1199 NESTED LOOPS (cr=8066 pr=4373 pw=0 time=10498695 us ...)
599 NESTED LOOPS (cr=6863 pr=3885 pw=0 time=20250270 us ...)
2057 TABLE ACCESS BY INDEX ROWID TRD100 (cr=2142 pr=2108 ...)
2057 INDEX RANGE SCAN DESCENDING IX_TRD100_01 (cr=163 pr=162 ...)
599 TABLE ACCESS BY INDEX ROWID TRM150 (cr=4721 pr=1777 ...)
599 INDEX UNIQUE SCAN PK_TRM150 (cr=4122 pr=1207 ...)
599 INDEX UNIQUE SCAN IX_TRM100_02 (cr=1203 pr=488 ...)
[A] WHERE 조회 조건
AND a.proc_stus IN ( 'D' , 'E' )
389
AND a.brof_cd LIKE TRIM( :b0 ) || '%'
[B] 인덱스 구성정보
INDEX_NAME COLUMN LIST
------------ ---------------------------------------
ix_trd100_01 brof_cd, proc_stus, acpt_dt, acpt_time
[C] ORDER BY (정렬 기준)
ORDER BY a.acpt_dt DESC,
a.acpt_time DESC
[D] ROWNUM 처리
WHERE ROWNUM <= :b2
[E] PLAN 상 OPERATION
50 COUNT STOPKEY (cr=8665 pr=4949 pw=0 time=31655952 us)
50 VIEW (cr=8665 pr=4949 pw=0 time=31655949 us ...)
50 SORT ORDER BY STOPKEY (cr=8665 pr=4949 pw=0 time=31655944 us ...)
----------------------------------------------------------------------------------------------
SELECT *
FROM ( SELECT ROWNUM rnum,
X.*
FROM (
SELECT * from ...
ORDER BY a.acpt_dt desc,
a.acpt_time desc ---> 문제점.Order By 절과 인덱스 구성순서와 다름.
) x
WHERE rownum <= :b2
)
WHERE rnum >= :b1 ;
SELECT *
FROM (
SELECT ROWNUM rnum,
X.*
FROM (
SELECT *
FROM ...
ORDER BY a.brof_cd desc,
a.proc_stus,
a.acpt_dt desc,
a.acpt_time desc --> 개선내용.Order By 절과 인덱스 구성순서와 맞춤
) x
WHERE ROWNUM <= :b2
)
WHERE rnum >= :b1 ;
SELECT *
FROM (
SELECT ROWNUM rnum , x.*
FROM (
SELECT /*+ LEADING(A) USE_NL(A B C) INDEX_DESC(A IX_TRD100_01) */
... 생략
FROM trd100 a ,
trm100 b ,
trm150 c
WHERE a.acpt_no = b.acpt_no
AND a.acpt_no = c.acpt_no
AND b.styl_cd = 'AC01'
AND a.proc_stus IN ( 'D' , 'E' )
AND a.brof_cd LIKE TRIM( :b0 ) || '%'
AND a.acpt_dt || a.acpt_time < :b1
ORDER BY a.brof_cd DESC ,
a.proc_stus DESC ,
a.acpt_dt DESC ,
a.acpt_time DESC
) x
)
WHERE rnum <= :b2 AND rnum >= :b3 ;
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 5 0.16 3.95 538 8677 0 50
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 7 0.17 3.96 538 8677 0 50
Rows Row Source Operation
---------- ---------------------------------------------------
50 FILTER (cr=8677 pr=538 pw=0 time=1957 us)
50 VIEW (cr=8677 pr=538 pw=0 time=1955 us cost=9 size=159 card=1)
599 COUNT (cr=8677 pr=538 pw=0 time=3261348 us)
599 VIEW (cr=8677 pr=538 pw=0 time=3260896 us cost=9 size=146 card=1)
599 TABLE ACCESS BY INDEX ROWID TRM150 (cr=8677 pr=538 ...)
1199 NESTED LOOPS (cr=8078 pr=538 pw=0 time=227759 us ...)
599 NESTED LOOPS (cr=6874 pr=530 pw=0 time=4307258 us ...)
2057 TABLE ACCESS BY INDEX ROWID TRD100 (cr=2147 pr=10 ...)
2057 INDEX RANGE SCAN DESCENDING IX_TRD100_01 (cr=167 pr=0 ...)
599 TABLE ACCESS BY INDEX ROWID TRM100 (cr=4727 pr=520 ...)
599 INDEX UNIQUE SCAN IX_TRM100_02 (cr=4128 pr=7 pw=0 time=56539 us ...)
599 INDEX UNIQUE SCAN PK_TRM150 (cr=1204 pr=8 pw=0 time=53068 us ...)
[A] WHERE 조회 조건
AND a.proc_stus IN ( 'D' , 'E' )
AND a.brof_cd LIKE TRIM( :b0 ) || '%'
[B] 인덱스 구성정보
INDEX_NAME COLUMN LIST
------------ ---------------------------------------
ix_trd100_01 brof_cd, proc_stus, acpt_dt, acpt_time
[C] ORDER BY (정렬 기준)
ORDER BY a.brof_cd DESC,
a.proc_stus DESC,
a.acpt_dt DESC,
a.acpt_time DESC
[D] ROWNUM 처리
WHERE rnum <= :b2 and rnum >= :b3
[E] PLAN 상 OPERATION
599 COUNT (cr=8677 pr=538 pw=0 time=3261348 us)
SELECT *
FROM (
SELECT ROWNUM rnum,
X.*
FROM (
SELECT * FROM ...
ORDER BY a.brof_cd desc,
a.proc_stus desc,
a.acpt_dt desc,
a.acpt_time desc
) x
)
WHERE rnum <= :b2 AND rnum >= :b3 ; ---> 문제점.ROWNUM 처리가 부적절
SELECT *
FROM (
SELECT ROWNUM rnum,
X.*
FROM (
SELECT * FROM ...
ORDER BY a.brof_cd desc,
a.proc_stus,
a.acpt_dt desc,
a.acpt_time desc
) x
WHERE ROWNUM <= :b2 ---> 개선내용.부분범위 처리가 되도록 ROWNUM 처리 변경
)
WHERE rnum >= :b3 ;
- 강좌 URL : http://www.gurubee.net/lecture/3836
- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^
- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.