If i understand the documentation correctly; the full hint should force a full table scan. In the below scenario it is not performing the same;
Num as in index created on it.
SQL> desc test;
Name Null? Type
----------------------------------------- -------- ----------------------------
NUM NOT NULL NUMBER
NUM2 NUMBER(10)
NUM3 NUMBER
Query:
select num from test;
Result:
NUM
----------
1
2
Execution Plan
Plan hash value: 410557223
-------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 4 | 1 (0)| 00:00:01 |
| 1 | INDEX FULL SCAN | ID | 2 | 4 | 1 (0)| 00:00:01 |
-------------------------------------------------------------------------
Query:
select /* +full(test) */ num from test;
Result:
NUM
----------
1
2
Execution Plan
Plan hash value: 410557223
-------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 4 | 1 (0)| 00:00:01 |
| 1 | INDEX FULL SCAN | ID | 2 | 4 | 1 (0)| 00:00:01 |
-------------------------------------------------------------------------
I understand i am selecting a value which is stored in the index. Addition of any other column makes the scan as full. Hence i have to ask the obvious. Is hint a request or is it a command to the optimizer ?
On a side note , what does computation of statistics have to do with optimization. Are the statistics of an index updated automatically or is this an explicit operation?
I haven’t tested this, but the correct syntax for using a hint is:
It’s slash-star-plus-space.