>select sp.STUDENTSEQ, a.User_ID
>from supprog sp
>join Advocate a on sp.ADVOCATE_CODE=a.Advocate_Code
>where a.USER_ID=37
>
>"PLAN JOIN (SP NATURAL, A INDEX (ADVOCATE_))" is slow.

Firebird simply thinks this is the best plan. As you know, it isn't and the 
simplest way to tell the optimizer that it should look for another plan is to 
add ||'' to your query at the correct place:

select sp.STUDENTSEQ, a.User_ID
from supprog sp
join Advocate a on sp.ADVOCATE_CODE=a.Advocate_Code||''
where a.USER_ID=37

This was a common way to prevent the optimizer to use a certain index in 
Firebird 1.5 and earlier, as the optimizer has improved this kind of tweaking 
has become less necessary.

HTH,
Set

Reply via email to