Subject | Indices and views |
---|---|
Author | Christian Gütter |
Post date | 2002-07-11T12:36:22Z |
Hi,
I have got a query which joins two tables (B: T_Bestellungen;
P: T_Projekte) and generates the following plan:
PLAN SORT (JOIN (B NATURAL, P INDEX(RDB$PRIMARY16))).
The "natural" sort of B is ok, because B is a small table.
This runs quite fast.
Then I created a view (V) on table P and modified my query.
The query now joins table B and view V.
This time I got the following plan:
PLAN SORT (JOIN (B NATURAL, T_PROJEKTE NATURAL)).
This takes very long, because no index is used for P (T_Projekte).
I tried to feed the following plan to the optimizer:
PLAN (JOIN(B NATURAL, P INDEX(RDB$PRIMARY16))) but then I get
an error: "index RDB$PRIMARY16 cannot be used in the specified plan".
So why does the optimizer refuse my plan?
And why doesn't it choose the right index when I join the table
with a view?
TIA,
Christian
I have got a query which joins two tables (B: T_Bestellungen;
P: T_Projekte) and generates the following plan:
PLAN SORT (JOIN (B NATURAL, P INDEX(RDB$PRIMARY16))).
The "natural" sort of B is ok, because B is a small table.
This runs quite fast.
Then I created a view (V) on table P and modified my query.
The query now joins table B and view V.
This time I got the following plan:
PLAN SORT (JOIN (B NATURAL, T_PROJEKTE NATURAL)).
This takes very long, because no index is used for P (T_Projekte).
I tried to feed the following plan to the optimizer:
PLAN (JOIN(B NATURAL, P INDEX(RDB$PRIMARY16))) but then I get
an error: "index RDB$PRIMARY16 cannot be used in the specified plan".
So why does the optimizer refuse my plan?
And why doesn't it choose the right index when I join the table
with a view?
TIA,
Christian