Subject Re[2]: [ib-support] WHERE optimization
Author Daniel Rail
Hi,

> Privet Sasha!

> At 11:47 13.02.2003 +0200, you wrote:
>>Does anybody know the order in which the predicates from the WHERE clause
>>of a SELECT statement execute.
>>
>>For example
>>
>>WHERE
>> PREDICATE_1 and PREDICATE_2 and PREDICATE_3
>>
>>which one is first

> I think this is determined by the plan. The plan tries to retrieve the
> records as cheap as possible, and will start by evaluating what it
> perceives to be the most restrictive predicate having an index (please
> correct me if I'm wrong).

I think it might also depend if some of those predicates are grouped
together by parentheses(ex. "(PREDICTATE_1 AND PREDICATE_2) AND
PREDICATE_3" ). And even using an OR might change things too. One
thing I noticed is that the optimizer seems to try to use indices that
englobe fields used in more than one predicate.

Maybe someone with more knowledge of the optimizer can give a better
answer(Arno!?).

Daniel Rail
Senior System Engineer
ACCRA Group Inc. (www.accra.ca)
ACCRA Med Software Inc. (www.accramed.ca)