... 11g CBO still allows the statistics done by ANALYZE? ...
yes, there is a difference between obsolete/deprecated/not supported (all of which are true for analyze table compute statistics) and "removed".
The RBO (rule based optimizer) is still in there - but it is obsolete, deprecated, not supported. There are thousands of things still in there that are in that state.
the costs just ended up being "a tie" - either way was better than good enough.
ops$tkyte%ORA10GR2> create table t as select empno, ename from scott.emp group by empno, ename;
Table created.
ops$tkyte%ORA10GR2> alter table t add constraint t_pk primary key(empno);
Table altered.
ops$tkyte%ORA10GR2> set autotrace traceonly explain
ops$tkyte%ORA10GR2> select * from t where empno > 0;
Execution Plan
----------------------------------------------------------
Plan hash value: 3772518221
------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 280 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 14 | 280 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | T_PK | 14 | | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("EMPNO">0)
Note
-----
- dynamic sampling used for this statement
ops$tkyte%ORA10GR2> select /*+ full(t) */ * from t where empno > 0;
Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 280 | 2 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T | 14 | 280 | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("EMPNO">0)
Note
-----
- dynamic sampling used for this statement
ops$tkyte%ORA10GR2> exec dbms_stats.gather_table_stats( user, 'T' );
PL/SQL procedure successfully completed.
ops$tkyte%ORA10GR2> select * from t where empno > 0;
Execution Plan
----------------------------------------------------------
Plan hash value: 3772518221
------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 126 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 14 | 126 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | T_PK | 14 | | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("EMPNO">0)
ops$tkyte%ORA10GR2> select /*+ full(t) */ * from t where empno > 0;
Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 126 | 2 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T | 14 | 126 | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("EMPNO">0)
ops$tkyte%ORA10GR2> set autotrace off
one of the things about teeny tiny things - they are not entirely representative