On Fri, 7 Jul 2017 11:27:26 -0300 Adriano dos Santos Fernandes wrote > > > It does not evaluate COALESCE at prepare time. > > It's just a expression which may or may not contain fields. > > If it doesn't contain fields, it will be the same as a simple "?" for > the plan calculation purposes. > >
OK. That is not the answer I was hoping for :-) 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. In fact, considering the index is a primary key where e.EMP_NO = NULL would make no sense at all. Surely the logic ought to be if unique index on field then use index Also, even though a field is specified in the coalesce why can't I force the plan... PLAN (E INDEX (RDB$PRIMARY7)) This error is raised... 'cannot be used in the specified plan' Paul -- Paul Reeves http://www.ibphoenix.com Supporting users of Firebird ------------------------------------------------------------------------------ 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