On 2017/09/14 7:10 PM, Simon Slavin wrote:

On 14 Sep 2017, at 5:55pm, R Smith <rsm...@rsweb.co.za> wrote:

Richard, wouldn't it be possible to supply a wrapping function (perhaps a hint 
function, like the likelihood() function), that takes another function as a 
parameter and then ensuring that THAT gets calculated only once?
Can you not do it with WITH ?  I don’t really understand how WITH works but it 
would seem to evaluate its terms just once for each iteration.

I think that's actually one of the things one of the posters tried and found not to work. The problem is the WITH syntax in theory is just-like constructing a temporary table and using the values from there, but in reality (AFAIK) it's just a mathematical construct that re-routes the query, so anything that is a parameter to a function (or a function itself) in the WITH clause gets re-evaluated every time the main query refers to the WITH table.

Perhaps if you can force the WITH into building an in-memory table with the results from, say a recursive function, it would indeed be a possibility, but I'm pretty sure that isn't a possibility. This is something easily done by the bigger engines since they rarely need to concern themselves with memory limitations, but then, for that same reason, they can (and do) just implement CSE without much fuss.

I was trying to posit a light-weight approach that puts a bit of onus on the programmer, but still answers the need - but no solution to this will be "quick and easy".


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to