Does Oracle support an optimization where boolean expressions are aborted
when further evaluation would not alter the outcome?
In other words, which of these selects is faster?:
1) select * from employees where
evaluation like '%recommend termination%' or
salary > 100000
2) select * from employees where
salary > 100000 or
evaluation like '%recommend termination%'
In these examples, the where clause should stop evaluating the
boolean expression as soon as further evaluation cannot change the
result. For example, in the expression (A or B), B never needs to
be evaluated if A is found to be true.
If this is the case with Oracle, then in the above two examples,
#2 should turn out to be faster because some fraction of the where
clause expressions would cease before performing the second (slow)
However, this presumes that the compiler preserves the order of
the subexpressions. Compilers don't always guarantee order
preservation. Some might even try to be so clever as to start
multiple simultaneous threads (one for each subexpression) and
treat the entire expression as a race condition.
So, how exactly does Oracle handle this? Is it the same for all
Thanks for the help. I'm sure a lot of people would be interrested
in this question if they don't already know the answer, so please