07.07.2017 17:07, Dmitry Yemanov wrote:
Given

   where e.EMP_NO = COALESCE(?, e.emp_no )

and that there is an index on EMP_NO, why doesn't the optimiser default
to the index. After all, it is logically more likely that a value will
be passed in the where condition, rather than a NULL.

To evaluate COALESCE, e.emp_no must be known. How it can be known before we start reading the table (via index scan)? Chicken and egg problem.

In this particular case it is enough to know parameter value to choose plan. Parameters are known before reading table.

--
  WBR, SD.

PS: Is it only my Thunderbird has started to send answers to authors instead of 
list?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to