> On Nov 10, 2017, at 9:51 AM, korablev <kitn...@gmail.com> wrote: > > I have noticed strange behaviour of user functions. Consider following > example:
In reports like this, it really helps if you can clearly state the situation at the start, instead of dumping hundreds of lines of code and output, and expecting the reader to figure out what’s going on. Down at the end: > So, change_global_var is called 3 times for -- one for inserting and two for > comparison. I expected that it would call function one time, save result and > use saved result for comparisons and insertion. This is what should have been at the top :) First off, you didn’t register the function as deterministic, so SQLite has to assume it can return a different result every time it’s called, even with the same arguments. That immediately prevents the kind of optimization you wanted. As for deterministic functions, I asked a similar question a month or two ago, about factoring multiple calls out of a query. You can find list archives and read the thread. It doesn’t sound likely to happen. —Jens _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users