Subject | Re: Re[2]: [firebird-support] Why PLAN token is not allowed after ORDER BY? |
---|---|
Author | Alec Swan |
Post date | 2012-06-02T21:37:52Z |
Dmitry,
If you look at the plans in my original post they both have "PHYSICAL_COPY
ORDER "IDX_214/CmDhH936xtHXcXNQKg=="
INDEX" just like you suggested. Sorry for the misleading table and index
names.
Once again, the plan I used was generated by FB query optimizer itself! I
did NOT create it by hand. What I did was this:
1. Ran a query which does "A LEFT JOIN B ORDER BY X" and copied the plan
that FB generated.
2. Changed the query to "A INNER JOIN B ORDER BY X PLAN P", where P is the
plan generated by FB in #1. Received "Unexpected token PLAN" error.
3. Change the query to "A INNER JOIN B PLAN P ORDER BY X" - success!
Why does #3 succeed but #2 fail?
Thanks,
Alec
If you look at the plans in my original post they both have "PHYSICAL_COPY
ORDER "IDX_214/CmDhH936xtHXcXNQKg=="
INDEX" just like you suggested. Sorry for the misleading table and index
names.
Once again, the plan I used was generated by FB query optimizer itself! I
did NOT create it by hand. What I did was this:
1. Ran a query which does "A LEFT JOIN B ORDER BY X" and copied the plan
that FB generated.
2. Changed the query to "A INNER JOIN B ORDER BY X PLAN P", where P is the
plan generated by FB in #1. Received "Unexpected token PLAN" error.
3. Change the query to "A INNER JOIN B PLAN P ORDER BY X" - success!
Why does #3 succeed but #2 fail?
Thanks,
Alec
On Sat, Jun 2, 2012 at 3:17 PM, Dmitry Kuzmenko <kdv@...> wrote:
> **
>
>
> Hello, Alec!
>
> AS> The question is why FB complains about PLAN token after ORDER BY
> clause?
>
> the answer is that PLAN is wrong. ORDER BY in query affects PLAN, it
> will contain PLAN SORT or TABLE ORDER INDEX specification. Your PLAN
> specification is crap, sorry for rude answer.
> As I said before, you need to know how Firebird produces plan
> specification and how it accepts it.
>
> --
> Dmitry Kuzmenko, www.ib-aid.com
>
>
>
[Non-text portions of this message have been removed]