Subject | Re: [firebird-support] Why is coalesce not using an index? |
---|---|
Author | Mark Rotteveel |
Post date | 2013-02-18T11:46:11Z |
On Mon, 18 Feb 2013 12:10:00 +0100, Carsten Schäfer <ca_schaefer@...>
wrote:
work if you have an expression index on COALESCE(apos.f_dat_anlieferung,
apos.f_dat_erstellung) (BTW: I am not 100% sure about this).
Mark
wrote:
>> Actually, I don't know whether Firebird treats coalesce as if OR hadThe optimizer in Firebird simply can't do this for a COALESCE. It might
>> been used. In some cases, I suspect it in theory could, but
>> COALESCE(a, b) IS NULL would have to translate to AND rather than OR.
>> Don't know whether this is implemented, or even if it would be
>> beneficial if implemented - whenever I use coalesce in a WHERE clause,
>> it is very rarely referring to different fields within the same tuple.
>>
> The comparison with your OR-example gives the same result.
> The OR uses both indexes and coalesce is not using the indexes.
> That's the problem.
work if you have an expression index on COALESCE(apos.f_dat_anlieferung,
apos.f_dat_erstellung) (BTW: I am not 100% sure about this).
Mark