Subject Re: [IBO] Speed and Indexes
Author Svein Erling Tysvær
Hi Hans!

>Is this caused by IB6 or IBO4 ?
This is caused by IB, not IBO. The problem is that the IB optimizer decides
to use both indexes in case 1. Whenever I use selects on statements like
this, I try to tune my SQL to use one index for each table only. In your
example, I guess I would have tried either

Select * from Table where a = :a and b = :b and (c = :c or 4=3)
or
Select * from Table where (a = :a or 3=2) and b = :b and c = :c

depending on which index was the most selective (you want to use the most
selective index).

Simple things like this can speed up the execution of selects a lot.

Set

>Hello Jason,
>Is this caused by IB6 or IBO4 ?
>Table with key fields a,b,c
>Case 1: 2 indexes (a,b) and (c)
>Case 2: 1 index (a,b,c)
>Select * from Table where a = :a and b = :b and c = :c
>
>is a couple of magnitudes slower in Case 1 than Case 2
>It sure pays off to closely examine the PLAN(s) shown by IB_WISQL
>even on fragments of stored procedures :)
>
>Best Regards
>Hans