Subject Re: Shocked by the optimizer (Arno, where art thou?)
Author Svein Erling Tysvær
Sorry for the long delay in answering, Steve.

I believed your suggestion to have helped, but the issue wasn't
whether it was possible to circumvent or improve the plan, but rather
that the optimizer failed to see the obvious plan in the first place
(it was a once-off query and I'd finished that work through hardcoding
the plan before even asking on this list).

As it turned out, when I finally tested with parenthesis, the same,
stupid plan was suggested (and that surprised me). I sent Arno a copy
of our table definitions and index selectivity, and maybe he has taken
a look at it to see why it chose the plan it did - I haven't heard
anything from him yet.

Set

--- In firebird-support@yahoogroups.com, Steve Wiser wrote:
> What about trying to put parentheses around the joins?
>
> SELECT * /*which fields are irrelevant, but I specified fields from
> all tables*/
> FROM ( TableA A
> JOIN TableB B on A.PK = B.Apk )
> LEFT JOIN TableC on B.PK = C.Bpk
> WHERE B.PK = 1
>
> Does that change the plan at all?
>
> -steve