the situation on my database
ezio, November 27, 2015 - 9:58 am UTC
Here is the result on my database,it seems that it is still goes the full table scan.
SQL> create table T ( x int not null, y date not null) ;
Table created.
SQL> insert /*+ APPEND */ into T
2 select rownum, sysdate + rownum/1000
3 from dual
4 connect by level <= 100000;
100000 rows created.
SQL> SQL> commit
2 ;
Commit complete.
SQL> create index IX on T ( y ) ;
Index created.
SQL> set autotrace traceonly explain
SQL> select max(y) from t;
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 SORT (AGGREGATE)
2 1 INDEX (FULL SCAN (MIN/MAX)) OF 'IX' (NON-UNIQUE)
SQL> select max(y) from t where 1=1;
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'T'
To: ezio | may be CBO no kicking in ?
Rajeshwaran, Jeyabal, November 27, 2015 - 10:21 am UTC
0 SELECT STATEMENT Optimizer=CHOOSE
Can we have stats gathering on table/index after the data load, before running queries ?
just run this " exec dbms_stats.gather_table_stats(user,'T',cascade=>true); " after the insert is done.
Connor, is on 12c database and stats gathering done as part of Direct path loads, but that is not the case with 9i database.