Subject Re: How to rename index without DROP / CREATE
Author Svein Erling Tysvær
--- In firebird-support@yahoogroups.com, "jstahl80" wrote:
> A query like
>
> select ...
> from wb_prg_run w inner join objectmap m on (w.objid = m.objid)
> inner join ch_pos_charge p on (m.to_objid = p.objid)
>
> uses plan join (m natural, w index, p index) under some special
> conditions (that I discussed very deeply on firebird-devel mailing
> list) where it would be better to use another ordering: plan join (p
> natural, m index, w index).
>
> objid is varchar field, I tried to use +'' in on clause without
> success.

select ...
from wb_prg_run w inner join objectmap m on (w.objid = m.objid)
inner join ch_pos_charge p on (m.to_objid = p.objid+'')

prevents using an index for p.objid in the JOIN ... ON clause (if
p.objid isn't a string, you may have to use 0 rather than ''). Of
course, a WHERE clause may make this index useful again, but the above
change is a strong hint to use P as the first table in the plan.

HTH,
Set
-am I optimized?