I guess my point is why doesn't the optimizer recognize the almost-zero cost of min/max in the compound query? It assumes instead to do it all in one scan.
So these two queries should be equal in speed and plan: select * from (select min(i) from test) as a,(select max(i) from test) as b, (select count(i) from test) as c; select min(i),max(i),count(i) from test; Michael D. Black Senior Scientist NG Information Systems Advanced Analytics Directorate ________________________________ From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of Simon Slavin [slav...@bigfraud.org] Sent: Saturday, June 25, 2011 10:38 AM To: General Discussion of SQLite Database Subject: EXT :Re: [sqlite] question about sqlite aggregate funcitons On 25 Jun 2011, at 4:12pm, Black, Michael (IS) wrote: > Can the optimizer recognize these "instant" functions and perhaps lean > towards using them? It already does. That's why max(x) takes no time when you have an index on (x). > Are there cases where this would NOT be good? Theoretically, the optimiser would recognise when this would not be good, and not dp it. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users