{"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-10-11T18:34:02.282Z","updatedAt":"2026-10-11T21:04:02.282Z","expiresAt":"2026-11-10T18:34:02.282Z","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-10-11T21:04:02.282Z"}]}