Subject RES: [firebird-support] No index used for join on 'starting with'
Author Fabiano
Please put your correct SQL here. Maybe the form you create your sql forces
a full table scan.

[] Em nome de Rick Debay
Enviada em: terça-feira, 10 de abril de 2012 14:12
Assunto: RE: [firebird-support] No index used for join on 'starting with'

Damn. Anyone know why the heck FB won't use an index in a join with
'starting with'?
FWIW, I ran the natural part of the query to generate a bunch of "starting
with 'xyx' or" and appended them to query the other table. Luckily I didn't
hit any query limits.

-----Original Message-----
<> ] On Behalf Of Svein Erling
Sent: Monday, April 09, 2012 3:29 PM
Subject: SV: [firebird-support] No index used for join on 'starting with'

>>This query uses natural for both tables, when I expected it to use an
>>index for the join.
>>select *
>>from table1 t1
>>join table2 t2 on t2.indexed_char14 starting with t1.indexed_char10
>>where t1.unindex_varchar containing 'foo'
>>This uses an index, so the optimizer knows about it.
>>select *
>>from table2 t2
>>where t2.indexed_char14 starting with 'bar'
>>How can I get the optimizer to use the index for the join?
>Anyone? Without any indexes, I won't live to see this complete.

Not a good suggestion (my simplified understanding of how Firebird JOINs
tables, may not be appropriate when STARTING WITH is part of the JOIN, so
I've no clue how to force that index), but I can think of two possible

An expression index and
join table2 t2 on substring(t2.indexed_char14 from 1 for 10) =

Add a calculated field
that you index and then change your JOIN to:
join table2 t2 on t2.indexed_char10 = t1.indexed_char10

Sorry for not having any better suggestions, Set

Disclaimer: This message (including attachments) is confidential and may be
privileged. If you have received it by mistake please notify the sender by
return e-mail and delete this message from your system. Any unauthorized use
or dissemination of this message in whole or in part is strictly prohibited.
Please note that e-mails are susceptible to change. RxStrategies, Inc. shall
not be liable for the improper or incomplete transmission of the information
contained in this communication or for any delay in its receipt or damage to
your system. RxStrategies, Inc. does not guarantee that the integrity of
this communication has been maintained nor that this communication is free
from viruses, interceptions or interference.

[Non-text portions of this message have been removed]