-- create a configuration favoring a full table scan and create a stored outline ;) ALTER SESSION SET optimizer_index_cost_adj = 10000 ; ALTER SESSION SET optimizer_index_caching = 1 ; ALTER SESSION SET db_file_multiblock_read_count = 32 ; ALTER SESSION SET optimizer_mode = all_rows ; alter session set create_stored_outlines = TRUE; CREATE OR REPLACE OUTLINE ol_tong FOR category hr_outlines ON SELECT count(DISTINCT line) FROM t1 WHERE owner = 'SYS' ; alter session set create_stored_outlines=FALSE; alter session set use_stored_outlines=hr_outlines; set autotrace traceonly explain SQL> SELECT count(DISTINCT line) 2 FROM t1 WHERE owner = 'SYS' ; Execution Plan ---------------------------------------------------------- Plan hash value: 3946799371 --------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 11 | 2544 (1)| 00:00:26 | | 1 | SORT GROUP BY | | 1 | 11 | | | |* 2 | TABLE ACCESS FULL| T1 | 17143 | 184K| 2544 (1)| 00:00:26 | <- opps a fts?? --------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter("OWNER"='SYS') Note ----- - outline "OL_TONG" used for this statement <- tiny little note here :) SQL> SELECT /*+ go_faster */ count(DISTINCT line) 2 FROM t1 WHERE owner = 'SYS' ; Execution Plan ---------------------------------------------------------- Plan hash value: 3456146945 --------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 11 | 1150 (1)| 00:00:12 | | 1 | SORT GROUP BY | | 1 | 11 | | | | 2 | TABLE ACCESS BY INDEX ROWID| T1 | 17143 | 184K| 1150 (1)| 00:00:12 | |* 3 | INDEX RANGE SCAN | NUI_T1 | 17167 | | 43 (3)| 00:00:01 | <- this time cbo chooses a better plan --------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("OWNER"='SYS')