[SQL튜닝]인덱스전체를 스캔할 경우 index_ffs를 사용하자.[오라클/ORACLE교육/오라클강좌/구로디지털단지오라클/실무오라클교육/재직자ORACLE교육]
아래는 전체테이블을 스캔할 경우인데 SELECT되는 컬럼으로 인덱스를 구성할 수 있다면
index_ffs 힌트를 사용할 만 하다.
-- 61초
with a as
( select ename, sal from myemp1
minus
select ename, sal from myemp1_old )
select count(ename) from a
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 52 | | 170K (1)
| 1 | SORT AGGREGATE | | 1 | 52 | |
| 2 | VIEW | | 20M| 991M| | 170K (1)
| 3 | MINUS | | | | |
| 4 | SORT UNIQUE | | 20M| 362M| 536M| 154K (1)
| 5 | TABLE ACCESS FULL| MYEMP1 | 20M| 362M| | 36473 (1)
| 6 | SORT UNIQUE | | 1999K| 38M| 53M| 15667 (1)
| 7 | TABLE ACCESS FULL| MYEMP1_OLD | 1999K| 38M| | 3481 (1)
--------------------------------------------------------------------------------
create index idx_myemp1_ename_sal on myemp1(ename, sal)
create index idx_myemp1_old_ename_sal on myemp1_old(ename, sal)
-- 44초
with a as (
select ename, sal
from myemp1 e1 where ename is not null and sal > 0
minus
select ename, sal
from myemp1_old e2 where ename is not null and sal > 0 )
select count(ename) from a
-----------------------------
| Id | Operation | Name | Rows | Bytes |Tem
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 52 |
| 1 | SORT AGGREGATE | | 1 | 52 |
| 2 | VIEW | | 19M| 991M|
| 3 | MINUS | | | |
| 4 | SORT UNIQUE | | 19M| 362M|
|* 5 | INDEX FAST FULL SCAN| IDX_MYEMP1_ENAME_SAL | 19M| 362M|
| 6 | SORT UNIQUE | | 1999K| 38M|
|* 7 | INDEX FAST FULL SCAN| IDX_MYEMP1_OLD_ENAME_SAL | 1999K| 38M|
--------------------------------------------------------------------------------
댓글 없음:
댓글 쓰기