Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> [Optimization] Early abort in boolean eval when possible?

[Optimization] Early abort in boolean eval when possible?

From: <scott_at_scam.XCF.Berkeley.EDU>
Date: 25 Mar 1999 18:00:17 GMT
Message-ID: <7ddtjh$cs7$1@agate.berkeley.edu>

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) term.

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 operating systems?

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 post here.

Thanks,

Scott Received on Thu Mar 25 1999 - 12:00:17 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US