Subject Re: Query optimization - Query PLAN
Author Dmitry Yemanov
18.06.2012 11:37, lacakus wrote:
>
> I guess, that it is because COALESCE is internaly transformed into CASE
> WHEN <subselect> IS NULL then 0 else <subselect> end
> So in expression is subselect twice.

Correct.

> My question is if <subselect> is really executed twice for every row in
> table1? or is there internal optimization where duplicate expressions
> are reduced?

Optimization happens only in Firebird 2.5 and above:
http://tracker.firebirdsql.org/browse/CORE-501


Dmitry