On Wed, 24 Apr 2013 17:46:00 +0100 Simon Slavin <slav...@bigfraud.org> wrote:
> 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 The order in which the columns appear syntactically in the GROUP BY clause is meaningless in SQL. Igor is correct that the query processor could use any index beginning with B,A or A,B, should it so choose. --jkl _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users