Optimizer question

  • From: Petr Novak <Petr.Novak@xxxxxxxxxxxx>
  • To: oracle-l <oracle-l@xxxxxxxxxxxxx>
  • Date: Wed, 6 Apr 2016 03:36:11 +0000

Hallo,



query on 11.2.0.4 DB



Table T has 1000000 rows, column A has all values Null, column B has 10 
different values , no Nulls.

Index on T(A,B) is defined, num_distinct for index is 10.



select * from T where A=?                             , where ? is not Null 
uses column statistics, expects 1 row, makes index scan

select * from T where A=? and B=?                , both not Null uses index 
statistics, expects 100000 rows, makes table full scan.



Why for the second query optimizer switched from using column statistics to 
index statistics ? It is some bug ? How to get correct plan for the second 
query ?





Best Regards,
Petr

Other related posts: