On Mon, Feb 28, 2011 at 6:23 PM, John <j...@rkroll.com> wrote: > Reading a little more about how the vdbe works and a little of the source > code, I then examined the output of explain. Explain shows that the > statement: > > select distinct x, abs(x) from T ; > > First loops over my T table and builds an Ephemeral table, which has an > index(?) that will allow sqlite to compute the distinct rows. It evaluates > the select terms x, abs(x) as it inserts the value of T into the Ephemeral > table. It then loops over the distinct values in the Ephemeral table to > generate the output result. The problem is that it uses the same select > terms ( x, abs(x) ) to create the result, instead of just using the already > computed values in the Ephemeral table. > > Is it possible to fix this so that functions that have side effects or are > time consuming to compute are called only once?
I recommend not having side-effects in user-defined (or any other) SQL functions. As for long-running functions, can you memoize them? I would think that you could. Nico -- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users