Subject | Re: PLAN |
---|---|
Author | Svein Erling |
Post date | 2004-05-11T08:38:07Z |
Rafael, my impression is that most people try to avoid writing
explicit plans and trust Arno (mr. Optimizer) to choose the best one
possible for them. In circumstances when he chooses a non-optimal
plan, the question is normally how to prevent using a certain index,
rather than to actually add another index to the plan.
I guess that BS_TRM_TRM_IDX cannot be used together with the indexes
you already mention (assuming you have tried) and most likely you
would only get worse performance if you tried forcing it using
something like:
PLAN JOIN( T ORDER(BS_TRM_TRM_IDX), I INDEX (FK_BS_IDX_COD_GRP,
COD_TRM_IDX))
(possibly ommitting either of the indexes for BS_IDX)
On the positive side: The index you already supply seems OK, at least
if the selectivity for the field I.COD_GRP is good.
Good luck in learning more about indexes. 17 May at 1:45pm I will
attend Arnos lecture about the optimizer at the Fulda conference.
**************************************************************
*** Set ***
*** ***
*** I support Firebird, I am a Firebird Foundation member ***
*** Join today at http://www.firebirdsql.org/ff/foundation ***
**************************************************************
explicit plans and trust Arno (mr. Optimizer) to choose the best one
possible for them. In circumstances when he chooses a non-optimal
plan, the question is normally how to prevent using a certain index,
rather than to actually add another index to the plan.
I guess that BS_TRM_TRM_IDX cannot be used together with the indexes
you already mention (assuming you have tried) and most likely you
would only get worse performance if you tried forcing it using
something like:
PLAN JOIN( T ORDER(BS_TRM_TRM_IDX), I INDEX (FK_BS_IDX_COD_GRP,
COD_TRM_IDX))
(possibly ommitting either of the indexes for BS_IDX)
On the positive side: The index you already supply seems OK, at least
if the selectivity for the field I.COD_GRP is good.
Good luck in learning more about indexes. 17 May at 1:45pm I will
attend Arnos lecture about the optimizer at the Fulda conference.
**************************************************************
*** Set ***
*** ***
*** I support Firebird, I am a Firebird Foundation member ***
*** Join today at http://www.firebirdsql.org/ff/foundation ***
**************************************************************
--- In firebird-support@yahoogroups.com, "Rafael Santini" wrote:
> Hi,
>
> I need help with this:
>
> select T.TRM from BS_IDX I, BS_TRM T
> where (I.COD_BASE = ? and I.COD_GRP = ?) and T.COD = I.COD_TRM
> group by T.TRM
> plan join (I INDEX (FK_BS_IDX_COD_GRP), T INDEX (PK_BS_TRM))
>
> The index for T.TRM column is BS_TRM_TRM_IDX. How to add this index
to PLAN
> clause ?
>
> Thanks,
>
> Rafael Santini