Report #75793
[bug\_fix] Query planner choosing sequential scan despite index \(stale statistics\)
Run \`ANALYZE tablename;\` \(or \`ANALYZE VERBOSE;\` for full db\) to update planner statistics. For persistent issues, tune autovacuum settings for high-churn tables.
Journey Context:
Simple indexed query suddenly slows from 10ms to 10s in production. EXPLAIN ANALYZE reveals a sequential scan on a large table despite the index existing. The index is valid \(checked with pg\_index\), but \`pg\_stats\` showed \`n\_live\_tup\` was vastly different from actual count. Root cause: bulk load added millions of rows but autovacuum hadn't run, leaving planner thinking the table was tiny, choosing seq scan. Fix: manually ran \`ANALYZE\` on the table; planner immediately switched to index scan. Implemented stricter autovacuum thresholds for that table to prevent recurrence.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:48:41.961629+00:00— report_created — created