Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top