Dmitry,
> > First, in the original example:
> > select u, u, u
> > from (select gen_uuid() u from rdb$database)
> >
> > there is only one instance of the expression -- there are 3 references to
> > the
> *resolved* expression.
>
> In Firebird, there is no such thing as "instance of the expression" or
> "resolved
> expression". All expression references are just copies of the original
> expression.
You said that they calculated the expression for each reference, thus the
expression can be said to be "unresolved". My point was that FB should be
"resolving"/calculating the expression once and then returning a
consistent/constant for all references for a given row.
> > P.S. This subject would extend to how the engine currently considers
> > all
> functions as "variant" (the answer changes with each call), where most
> functions/UDFs are "invariant". This causes optimization problems in cases
> where the SQL reads:
> >
> > SELECT ... FROM ... WHERE ColumnA = COS( :Param)
> >
> > In this case, the result of the COS() function is a fixed value and thus the
> optimizer should use any ColumnA index, but it doesn't.
>
> I don't get the point, sorry. Are you talking about caching invariant
> expression
> results or about index based optimizations? Predicate like "ColumnA =
> COS(:Param)" will always use an index for ColumnA regardless of whether
> COS is variant or invariant.
Bad example, I should have said that:
SELECT ... FROM ... WHERE ColumnA = COS( ColumnB)
Doesn't use an index when it should be able to, just as the engine is able to
use an index for this query
SELECT ... FROM ... WHERE ColumnA = ColumnB
Sean
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel