Subject | RE: [firebird-support] Query optimization mystery |
---|---|
Author | Svein Erling Tysvær |
Post date | 2014-05-14T07:56:43Z |
>select sp.STUDENTSEQ, a.User_IDFirebird 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:
>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.
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