07.07.2017 17:51, Paul Reeves wrote:

But that doesn't answer all my questions...

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.


Dmitry

------------------------------------------------------------------------------
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