Subject Re: Query appears to put Firebird into a loop
Author Stephen Boyd
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær
<svein.erling.tysvaer@...> wrote:
>

Svein;

Thank you for the marvelously clear explanation of what was going on.
Once you explained it, the solution occurred to me.

Rather than hard coding B.LDS_TEMPLATE_FLAG = 'N' and
E.LD_TEMPLATE_FLAG = 'N' I changed them to B.LDS_TEMPLATE_FLAG =
A.LD_TEMPLATE_FLAG and E.LD_TEMPLATE_FLAG = D.LDS_TEMPLATE_FLAG. Both
forms are logically equivalent, in that they return the same result
set, but the second form is much faster. It prevented Firebird from
rearranging the order of the indices in the plan and now the query
completes in seconds.

Thank You