Subject | Re: No index used for join on 'starting with' |
---|---|
Author | Dmitry Yemanov |
Post date | 2012-04-11T08:15:40Z |
11.04.2012 1:49, unordained wrote:
for some value by its key you should have that key already retrieved.
Just think more about it and you should get the idea.
both tables should be accessed twice with different rules. It's improved
in FB3.
side to the right side.
Dmitry
> select 1 from bt_dchronexpl inner join bt_ref on bt_ref.file_num =It's impossible to use two indices for a single condition. If you search
> bt_dchronexpl.filenumber;
> --> PLAN JOIN (BT_DCHRONEXPL NATURAL, BT_REF INDEX (IX_BT_REF_FILE_NUM_ASC))
> -- so it CAN use an index, but why not both? just the size imbalance?
for some value by its key you should have that key already retrieved.
Just think more about it and you should get the idea.
> select 1 from bt_dchronexpl full outer join bt_ref on bt_ref.file_num =FULL OUTER JOIN could never use indices due to its implementation, as
> bt_dchronexpl.filenumber
> --> PLAN JOIN (BT_REF NATURAL, BT_DCHRONEXPL NATURAL)
> -- why no index at all?
both tables should be accessed twice with different rules. It's improved
in FB3.
> select 1 from bt_dchronexpl right join bt_ref on bt_ref.file_num startsBecause LEFT/RIGHT JOIN always dictates the join order, from the left
> with
> bt_dchronexpl.filenumber;
> --> PLAN JOIN (BT_REF NATURAL, BT_DCHRONEXPL NATURAL)
> -- why not a reversed looping lookup?
side to the right side.
> select 1 from bt_dchronexpl left|inner|right join bt_ref on bt_ref.file_numSee my first comment.
> starts with bt_dchronexpl.filenumber
> PLAN JOIN (BT_DCHRONEXPL INDEX(IX_DCHRONEXPL_FILENUM), BT_REF INDEX
> (IX_BT_REF_FILE_NUM_ASC))
> --> ERROR: index IX_DCHRONEXPL_FILENUM cannot be used in the specified plan
Dmitry