Aly Hirani <alyhir...@gmail.com> wrote: > I had 2 questions: > > 1) Given the query: > > SELECT col1 FROM table WHERE col2 = ? GROUP BY col3, col4 ORDER BY col5, > col6, col7, col8;
What does this query mean? If col5, col6, col7 and col8 vary within a group defined by col3, col4, how exactly should these groups be ordered? > What would be the "right" index to create? > > I was thinking it would be: > > CREATE INDEX index1 ON table (col2, col3, col4, col5, col6, col7, col8); Yes, this or any initial prefix thereof. > 2) If there are no aggregates column present in a query, are GROUP BY > essentially ORDER BYs semantically? (such as in the query above) No. ORDER BY doesn't change the number of rows returned, GROUP BY may. -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users