On 24 Apr 2013, at 5:14pm, Igor Tandetnik <i...@tandetnik.org> wrote:

> Note though that the query doesn't have an ORDER BY clause. It doesn't 
> request rows in any particular order. SQLite could, in principle, reorder 
> columns in GROUP BY to take advantage of the index. I suppose the optimizer 
> just happens to miss this particular opportunity.

But the GROUP BY clause has an order:

>> Query 1:  SELECT A,B,count(*) from tableTest group by A,B
>> Query 2:  SELECT A,B,count(*) from tableTest group by B,A

which is pretty much the same as having two different ORDER BY clauses.  An 
index which is ideal for one of those is not ideal for the other.  I don't find 
it weird that the optimiser would decide to use an index for one of them but 
not the other.

To the original poster: do an ANALYZE, then see if you get different timings 
afterwards.

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

Reply via email to