OK, in trying to clear up one misunderstanding I've created another, so let me be clear: I don't support automatic CSE, I think it should be done manually. But to support that Richard, can you answer this question: is there a way of ensuring that a particular expression (or just function call) will be guaranteed to be evaluated before any other in a particular statement?
> On Sep 14, 2017, at 4:13 PM, Richard Hipp <d...@sqlite.org> wrote: > > On 9/14/17, Darko Volaric <li...@darko.org> wrote: >> I think people are missing the point, probably becuase it's not a great >> example. Consider the following statement: >> >> SELECT funca(slow(10)), funkb(slow(10)) >> >> and lets say slow(10) takes an hour to compute, and funka and funkb take >> almost no time to execute. With common subexpression optimization the >> statement would take one hour, instead of two, to compute becuase the value >> of slow(10) would only be calculated once. > > I fully understand the benefits of CSE. My point is that constructs > such as the above are very rarely used in SQLite - so much so that the > amount of extra time spent inside of sqlite3_prepare() in order to > deal with them is not worth the effort. > > CSE in the example you cite above is relatively easy. A harder example is > this: > > SELECT coalesce(x, slow(10)), coalesce(y, slow(10)) FROM tab; > > -- > D. Richard Hipp > d...@sqlite.org > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users