Subject | Re: Possible BUG in PLAN Optimizer ? FB 1.5.4290 |
---|---|
Author | Svein Erling |
Post date | 2004-04-30T09:11:49Z |
--- In firebird-support@yahoogroups.com, "Helmut Hartl" wrote:
looking at your original plan
PLAN JOIN (C NATURAL,B INDEX (PK_T2),A INDEX (T1_IDX1,PK_T1))
I notice that it uses two indexes for A and none for C. The plan you
reported as quicker, uses similar indexes, but not PK_T1.
PLAN JOIN (A INDEX (T1_IDX1),B INDEX (FK_T2),C INDEX (FK_T3))
So we want to prevent the query from using PK_T1, just to see if it
then chooses the quicker plan. Since the optimizer doesn't know that
A.ID = A.ID+0 and has no index for A.ID+0, that trick works in
preventing certain indexes from being used. Of course, adding +0
everywhere simply forces NATURAL all over the place, something that
generally is no good idea, but as you say used in the right place it
can be useful.
Set
> Hello Svein !Hi again, Helmut, glad to hear that it worked. I put it there because
>
> Your trick with a.id+0 speeds up my App from 60 Seconds to nearly
> zero. I am really happy with your answer !! :-)
>
> Can you give me a hint, why this is so ?
>
> I just experimented a bit and adding 0 to other ID's in the JOIN
> will make the behaviour even worse by tripling and doubling the
> time. But in the right place it works like magic.
looking at your original plan
PLAN JOIN (C NATURAL,B INDEX (PK_T2),A INDEX (T1_IDX1,PK_T1))
I notice that it uses two indexes for A and none for C. The plan you
reported as quicker, uses similar indexes, but not PK_T1.
PLAN JOIN (A INDEX (T1_IDX1),B INDEX (FK_T2),C INDEX (FK_T3))
So we want to prevent the query from using PK_T1, just to see if it
then chooses the quicker plan. Since the optimizer doesn't know that
A.ID = A.ID+0 and has no index for A.ID+0, that trick works in
preventing certain indexes from being used. Of course, adding +0
everywhere simply forces NATURAL all over the place, something that
generally is no good idea, but as you say used in the right place it
can be useful.
Set