Subject Why is coalesce not using an index?
Author Carsten Schäfer
I have this simple select
select sum(apos.f_gewicht) as Gewicht
from t_apos apos
where COALESCE(apos.f_dat_anlieferung, apos.f_dat_erstellung) between
'2013-01-15' and '2013-01-16'
which does an natural scan on table t_apos although an index is on both
fields.

select sum(apos.f_gewicht) as Gewicht
from t_apos apos
where apos.f_dat_anlieferung between '2013-01-15' and '2013-01-16'

and

select sum(apos.f_gewicht) as Gewicht
from t_apos apos
where apos.f_dat_erstellung between '2013-01-15' and '2013-01-16'

both uses the index .
Why is the index not used when coalesce is used?
I use Firebird 2.5.2 64bit on Windows 7.

Carsten