I dont have "explain plan" on hand. Could you help to tell which of the below is more efficient?
Option 1:
select ...
from VIEW_ABC
where STRING_COL = 'AA'
OR STRING_COL = 'BB'
OR STRING_COL = 'BB'
OR ...
OR STRING_COL = 'ZZ'
Option 2:
select ...
from VIEW_ABC
where STRING_COL IN ('AA','BB',...,'ZZ')
This is a similar question: IN vs OR of Oracle, which faster?
Look at the answer given by OMG Ponies, he suggests that IN
is more optimized than OR
.
There is also this question: IN vs OR in the SQL WHERE Clause
Though it is non database specific, it has a few good answers from an Oracle perspective.
For what it's worth, the use of IN
would be far easier to read and therefore easier to support in the long run. That alone might sway your choice, especially if (as I suspect) the Oracle optimiser treats them both the same way.
If, however, your list of values is very large then you should probably look into a totally different method for retrieving your results.
I would assume the optimizer would treat both versions the same. IN
is really just syntactic shorthand for multiple OR
statements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With