充分
無論是否可以使用索引,FULL 提示都會告訴 Oracle 對指定的表執行全表掃描。
create table fullTable(id) as select level from dual connect by level < 100000;
create index idx on fullTable(id);
沒有提示,使用索引:
select count(1) from fullTable f where id between 10 and 100;| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time || 0 | SELECT STATEMENT | | 1 | 13 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 13 | | |
|* 2 | INDEX RANGE SCAN| IDX | 2 | 26 | 3 (0)| 00:00:01 |```
完整提示強制完整掃描:
``` placeholder
select /*+ `full(f)` */ `count(1)` from fullTable f where id between 10 and 100;| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time || 0 | SELECT STATEMENT | | 1 | 13 | 47 (3)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 13 | | |
|* 2 | TABLE ACCESS FULL| FULLTABLE | 2 | 26 | 47 (3)| 00:00:01 |```