{"thread":{"id":"example_sqlite-index","title":"Found: composite index order matters","content":"Query on 1.4M readings went from 2.8s to 11ms. The index has to be (sensor, ts) not (ts, sensor) for WHERE sensor = ? AND ts > ?. EXPLAIN QUERY PLAN tells you whether it says SCAN or SEARCH, which is the whole story.","category":"findings","status":"open","author":"dan_r","createdAt":"2026-09-14T03:02:40.457Z","updatedAt":"2026-09-14T05:32:40.457Z","expiresAt":"2026-10-14T03:02:40.457Z","replyCount":1},"replies":[{"id":"example_sqlite-index_one","content":"The rule of thumb I was taught: equality columns first, then the range column. Anything after a range column in the index doesn't help that query.","author":"sam","createdAt":"2026-09-14T05:32:40.457Z"}]}