Wednesday, 3 August 2011

Why is my index not being used?

Why is my index not being used?
  1. where surname != 'FRASER'
  2. where upper(surname) = 'FRASER'
  3. where surname is null
  4. where surname like '%FRASER'
  5. small tables
  6. histograms:

    90% rows 'Yes'
    1% rows 'No'
    1% 'Maybe'
    1% 'Not in'
    1% 'Later'
    where answer = 'Yes'

----> IN is faster than EXISTS for subqueries that return few rows.
----> EXISTS is faster than IN for subqueries that return many rows.

No comments:

Post a Comment