perf: Add periodic PRAGMA optimize/ANALYZE to keep planner stats fresh

#17 · open · 0 comments

View on GitHub ↗

InterferencePattern

## What to build There is no periodic `ANALYZE` / `PRAGMA optimize` anywhere — `sqlite_stat1` only refreshes when run by hand, which is the root cause of the April retention crash (stale stats → wrong index → full scan). Add a scheduled job (e.g. a daily Oban worker) that runs `PRAGMA optimize` (or `ANALYZE`) so planner statistics stay current automatically and future index changes never need a manual ANALYZE. ## Acceptance criteria - [ ] A scheduled job runs `PRAGMA optimize`/`ANALYZE` on a sensible cadence (e.g. daily) - [ ] The job is cheap and does not block normal operation - [ ] Verified that planner stats refresh without manual intervention - [ ] Test covers the job enqueues/runs ## Blocked by None - can start immediately

Comments