On 25 Jun 2011, at 7:14pm, Black, Michael (IS) wrote:

> 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.

Because it's almost impossible to optimize sub-SELECTs.  You pretty-much have 
to perform the sub-SELECT and look at the results before you can figure out how 
to optimise it.

If you want good optimisation, use JOIN, which part of the SQL standard and has 
a syntax which leads to easier optimization.

> select * from (select min(i) from test) as a,(select max(i) from test) as b, 
> (select count(i) from test) as c;

That makes no sense in terms of what you'd really want to do with a database, 
so the optimizer is going to have trouble with it.

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to