Why does the Oracle execution plan change based on a where clause value alone? I'm not talking bind variables, but in-place values in the SQL.
For example running Explain Plan on these queries in SQL Developer:
select col1, col2 from table1 where col1 >= '4520/85/36 99.99.99'; -- uses index on col1
select col1, col2 from table1 where col1 >= '4520/85/36 00.00.00'; -- full table scan
What can cause Oracle to choose a different execution plan like this? FYI, neither of the above values exist in the table, but they represent a range of numerically related values.
Another observation, by simply removing the other column changes the execution plan again:
select col1, col2 from table1 where col1 >= '4520/85/36 00.00.00'; -- full table scan
select col1 from table1 where col1 >= '4520/85/36 00.00.00'; -- uses index on col1
If the question is not clear, please let me know what further information would be helpful.
Edit: I have rebuilt the table indexes and gathered statistics, I have even dropped and recreated the index. The number of rows in this table is around 12 million.