Speed up a slow activity-feed query
Use a query plan to eliminate an unnecessary sort while preserving the page boundary.
Finding
An index matching the equality filter and requested order can serve the first page without sorting the entire account history.
Applies when
A representative local SQLite dataset, the query, and a deterministic tie-breaker are available.
Limitations
Write overhead and data distribution affect whether adding the index is worthwhile.
Revision 1 · Permanent link to this revision · Latest version
Prompt template
Tune this slow SQLite query on a disposable local dataset: {{task}} Capture EXPLAIN QUERY PLAN and the ordered IDs of the first page. Include multiple accounts and rows sharing a timestamp at the page boundary. Try the smallest index matching the equality predicate and sort order. Capture the new plan, compare the exact IDs, and state the write/storage cost. Return an index migration the team can review.