Subject | Re: [ib-support] Indexes and Joins |
---|---|
Author | Svein Erling Tysvær |
Post date | 2002-04-04T09:35:04Z |
Daniel,
since it is the first table in your plan IB/FB cannot benefit from using an
index on this table.
That is not to say that your cannot get a better plan (and that is a lot
more complicated). I would try to move SO up on top of your plan somehow.
Try making a composite index on (STATUS, INVOICENUMBER, DATECOMPLETED) or
something and then make sure you have an index on
CLIENTBILLTO.CLIENTBILLTOID as Daniel (Rail) said. Then your plan should
become something like
PLAN
SORT
(JOIN
(JOIN
(SO INDEX (SERVICEORDER_STATUS_INVOICENUMBER_DATECOMPLETED),
CL INDEX (RDB$PRIMARY13),
BT INDEX (CLIENTBILLTO_CLIENTBILLTOID)
),
PD INDEX (PARTDETAIL_SO)
)
)
which ought to be a bit faster (if CLIENTBILLTO_CLIENTBILLTOID is already
your PK or something, use this rather than create a new index). Note that
the order of the tables matter in the plan.
HTH,
Set
>PLANThis is simple - you have not restricted BT through your WHERE clause, and
> SORT
> (JOIN
> (JOIN
> (BT Natral,
> CL INDEX (RDB$PRIMARY13),
> SO INDEX (SERVICEORDER_COMPLETEDATE,
> SERVICEORDER_CLIENTBILLTOID,
> SERVICEORDER_STATUS
> )
> ),
> PD INDEX (PARTDETAIL_SO)
> )
> )
>If I try to use **BT INDEX (RDB$PRIMARY14)**, IB
>complains that that index cannot be used. That is the
>primary key for that table.
>Any ideas why it cannot be used?
since it is the first table in your plan IB/FB cannot benefit from using an
index on this table.
That is not to say that your cannot get a better plan (and that is a lot
more complicated). I would try to move SO up on top of your plan somehow.
Try making a composite index on (STATUS, INVOICENUMBER, DATECOMPLETED) or
something and then make sure you have an index on
CLIENTBILLTO.CLIENTBILLTOID as Daniel (Rail) said. Then your plan should
become something like
PLAN
SORT
(JOIN
(JOIN
(SO INDEX (SERVICEORDER_STATUS_INVOICENUMBER_DATECOMPLETED),
CL INDEX (RDB$PRIMARY13),
BT INDEX (CLIENTBILLTO_CLIENTBILLTOID)
),
PD INDEX (PARTDETAIL_SO)
)
)
which ought to be a bit faster (if CLIENTBILLTO_CLIENTBILLTOID is already
your PK or something, use this rather than create a new index). Note that
the order of the tables matter in the plan.
HTH,
Set