RE: Optimizing a Simple 'select count(*)'

  • From: "Tefft, Michael J" <Michael.J.Tefft@xxxxxxxxxx>
  • To: "Mark.Bobak@xxxxxxxxxxxx" <Mark.Bobak@xxxxxxxxxxxx>, "fmhabash@xxxxxxxxx" <fmhabash@xxxxxxxxx>, "oracle-l@xxxxxxxxxxxxx" <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 7 Mar 2014 19:23:25 +0000

It is not necessary for completion_time to be NOT NULL for a index on that 
column to be suitable for this query.

Suppose you have rows that have completion_time as null? So what? That 
predicate will exclude them anyway - and the optimizer knows this, and it will 
gladly use an index on completion_time if it exists (and if it makes sense).
The biggest question is: Does an index actually exist, with that column?

I don't think that has not been explicitly stated, and I have had (a few) 
occasions when I struggled for hours with the question 'why won't it use the 
index on that column' because I assumed it had to exist, but never verified it 
was really there.

Mike

Other related posts: