Table Full Scan Cost
Cost = Single Block I/O Count + Adjusted Multi Block I/O Count + Adjusted CPU Count
Blocks = 100, MBRC = 4, sreadtim = 5, mreadtim = 10 |
Index Scan Cost
Cost = Blevel + Leaf Blocks * Index Selectivity + Clustering Factor * Table Selectivity + Adjusted CPU Count
Total Rows = 100000, Total Blocks = 10000, MBRC = 10, Index Height = 3(Blevel = 2), Leaf Blocks = 100, Clustering Factor = 50000 |
Index Scan Cost에서 Clustering Factor가 차지하는 비중이 높다.
Index에 대해 넓은 범위의 Leaf Block을 Scan하는 경우에는 Cost가 높다.(즉, Selectivity가 차지하는 비중이 높다.)
Table Full Scan의 Cost는 MBRC값에 크게 의존한다.
EXPLAIN PLAN FOR
SELECT /*+ GOOD CLSF */
*
FROM T_CLSF
WHERE C1 BETWEEN 1
AND 100
;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 100 | 700 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T_CLSF | 100 | 700 | 3 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | T_CLSF_I1 | 100 | | 2 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------
;
EXPLAIN PLAN FOR
SELECT /*+ BAD CLSF INDEX(T_CLSF) */
*
FROM T_CLSF
WHERE C2 BETWEEN 1
AND 100
;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 100 | 700 | 97 (0)| 00:00:02 |
| 1 | TABLE ACCESS BY INDEX ROWID| T_CLSF | 100 | 700 | 97 (0)| 00:00:02 |
|* 2 | INDEX RANGE SCAN | T_CLSF_I2 | 100 | | 2 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------