Subject Re: [firebird-support] Query tuning help
Author Arno Brinkman

> >> WHERE
> >> (Table4.ForeignKey1 = 170) and
> >> ( ((Table1.ForeignKey2 = 962) and (Table1.Status = 8)) or
> >> ((Table1.ForeignKey2 = 963) and (Table1.Status = 8)))
> Just tried it now, and it is much faster. Also tried it back on FB 1 and
> it also is much faster (returns in a few seconds rather than hours).

Is there a compound index on ForeignKey and Status or is there a single
index on both of them?

> Is there any guide line on how you should structure these queries since
> they produce drastically different performance results? Or do you just
> keep on mucking with it until you find something that works (or works
> fast enough?).

At least try to keep only the fields from the same table together in a OR
condition, but this depends on the selectivity from the used fields.

Arno Brinkman

Firebird links :

Nederlandse firebird nieuwsgroep :