Domanda

Is there any major query performance difference between IN and NOT IN operators in oracle database?

È stato utile?

Soluzione

Like most performance questions, it depends.

If there are no indexes then they should be roughly comparable.

If you have an index on the limiting column then IN will likely be faster than NOT IN as IN can use an index seek while NOT IN will require a table scan.

The above depends of course, if there are very few distinct values of col1 and it's indexed, then NOT IN could end up using an index seek rather than a table scan.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top