h1.04 Prefetch
prefetch 건수와 prefetch후 사용하지 않은 블록량 조회
select name, value from v$sysstat
where name in ('physical reads cache prefetch'
,'prefetched blocks aged out before use');
NAME VALUE
-------------------------------------------------
physical reads cache prefetch 696866478
prefetched blocks aged out before use 2073208
h3.(1) 인덱스 Prefetch
h3.(2) 테이블 Prefetch
테이블 prefetch 테스트
--prefetch 기능을 비활성화하여 조회
SELECT /*+GATHER_PLAN_STATISTICS INDEX(A TABLE_A_IDX1) NO_NLJ_PREFETCH(B) */
*
FROM TABLE_A A, TABLE_B B
WHERE A.COL1 = '2016-12-31'
AND A.COL2 LIKE 'O%'
AND A.COL3 BETWEEN 1 AND 5000
AND A.COL4 = B.COL4
-------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
-------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 106K|00:00:00.72 | 65050 |
| 1 | NESTED LOOPS | | 1 | 77 | 106K|00:00:00.72 | 65050 |
| 2 | TABLE ACCESS BY INDEX ROWID| TABLE_A | 1 | 3 | 12985 |00:00:00.14 | 12117 |
|* 3 | INDEX RANGE SCAN | TABLE_A_IDX1 | 1 | 3 | 12985 |00:00:00.03 | 2486 |
| 4 | TABLE ACCESS BY INDEX ROWID| TABLE_B | 12985 | 28 | 106K|00:00:00.55 | 52933 |
|* 5 | INDEX RANGE SCAN | TABLE_B_IDX6 | 12985 | 28 | 106K|00:00:00.23 | 39622 |
-------------------------------------------------------------------------------------------------------
--table prefetch로 조회
SELECT /*+GATHER_PLAN_STATISTICS INDEX(A TABLE_A_IDX1)*/
*
FROM TABLE_A A, TABLE_B B
WHERE A.COL1 = '2016-12-31'
AND A.COL2 LIKE 'O%'
AND A.COL3 BETWEEN 1 AND 5000
AND A.COL4 = B.COL4
--------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
--------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 0 | | 0 |00:00:00.01 | 0 |
| 1 | TABLE ACCESS BY INDEX ROWID | TABLE_B | 1 | 28 | 106K|00:00:00.78 | 65050 |
| 2 | NESTED LOOPS | | 1 | 77 | 119K|00:00:00.43 | 51739 |
| 3 | TABLE ACCESS BY INDEX ROWID| TABLE_A | 1 | 3 | 12985 |00:00:00.15 | 12117 |
|* 4 | INDEX RANGE SCAN | TABLE_A_IDX1 | 1 | 3 | 12985 |00:00:00.03 | 2486 |
|* 5 | INDEX RANGE SCAN | TABLE_B_IDX6 | 12985 | 28 | 106K|00:00:00.24 | 39622 |
--------------------------------------------------------------------------------------------------------