Is it possible to rewrite a NOT IN query to use indexes?

Viewed 107

Sqlite does not support the use of indexes in queries based around a NOT IN clause.

Is it possible to logically rewrite a query like the following in such a way that it will only use the operators listed at the link above?

The query:

Select *
From table
Where table-column not in (
    Select table-column
    From table2);

The operators listed as being able to use an index:

  • column = expression
  • column > expression
  • column >= expression
  • column < expression
  • column <= expression
  • expression = column
  • expression > column
  • expression >= column
  • expression < column
  • expression <= column
  • column IN (expression-list)
  • column IN (subquery)
  • column IS NULL
3 Answers
Related