On Thursday, 14 September, 2017 19:05, Jens Alfke <j...@mooseyard.com>, wrote:
>> On Sep 14, 2017, at 1:23 PM, Keith Medcalf <kmedc...@dessus.com> >wrote: >> You merely need to ONCE it either for each input row or for each >result row. So for example: >> select slow(a.x), slow(a.x)*slow(b.y), slow(b.y) from a, b where >a.this == b.that >> when computing the result set you merely compute ONCE slow(a.x) and >ONCE slow(b,y) >Interesting … I assume ONCE is something internal to the SQLite query >engine? I don't see any reference to it in the SQL syntax or the >other docs. >Is there any way to achieve this effect without modifying SQLite? Yes, it is an internal thing in the VDBE code. It is currently used so that certain things can be done only ONCE per execution of the prepared statement (that is, to generate certain constants that once created do not change throughout the entire execution (from the first step until reset), but will be regenerated if the statement is reset then run again)). It basically an if type construct for example: once r5 { r5 = (do something) } So the first time it is run, r5 is unintialized something is done to compute a value stored in r5. On the next step the value of r5 already exists so the computation steps are skipped. Of course, in this case the calculation is "per step" and you are just ignoring duplicate calculations, so it is similar but not really the same thing. This type of optimization would at least prevent multiple executions of the function with the same arguments *in the same step* but would not prevent execution with the same arguments in different steps. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users