Jean-Marie CUAZ <jm.c...@orens.fr> wrote:
> When using a SELECT query with WHERE and GROUP BY clauses, does it make
> sense to add the GROUP BY terms in an index allready containing the
> columns used in the WHERE clause ?

In some cases, it might help. If you have something like

select * from t where a=42 group by b;

then an index on t(a, b) is useful. SQLite would use it to find all records 
with a=42 and enumerate them in the order sorted by b.

> If yes, should the columns used in the GROUP BY clause be at the
> beginning of the columns order of the index ?

Again, depends on the exact query. The example above works best with b at the 
end.
-- 
Igor Tandetnik

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

Reply via email to