Marc L. Allen wrote, On 26/04/12 15:30:
I suppose using a temporary table is out of the question?

It's much simpler (and probably quicker though I didn't test it) to read the three rows, sort them by date, pick the first row and use that. No need to generate random table names, create and drop the table.

Python time.time() gives 0.001sec for all that (to 3 dec places) which is fast enough for me ;) (and faster than PostgreSQL at 0.023 using the plain query).

 But, then
again, that only solves the specific issue.  I guess the more general
question is how views with unions interact with aggregates and order
by.

What happens if you don't use the view, but perform the query using
the actual tables?

Makes no difference - the planner is still using the scans instead of indexes.

--

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

Reply via email to