On 7 Feb 2018, at 12:43am, Mark Wagner <[email protected]> wrote: > CREATE TABLE foo (_id integer primary key, x, y); > CREATE INDEX i on foo(_id, x, y); > > And the following query > > sqlite> EXPLAIN QUERY PLAN SELECT * FROM foo WHERE x=1 GROUP BY _id ORDER > BY y;
Why are you grouping on the primary key ? Primary key values must be, by definition, unique. Grouping by a unique value means every group has one entry. There's a similar problem with the index you created. Since the primary key is first, there's no point in having the x and y in the index. Therefore there's no point in having the index since it just duplicates the primary key index for the table. I suspect that SQLite is acting weird because you fed it with weird things. Simon. _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

