Fix: Postgres Slow Query
Run `EXPLAIN (ANALYZE, BUFFERS)` in prod
Slow Postgres queries are almost always a missing index, a bad plan from stale stats, or a large sequential scan. `EXPLAIN ANALYZE` shows which.
Frequently Asked Questions
What causes Postgres Slow Query?
Slow Postgres queries are almost always a missing index, a bad plan from stale stats, or a large sequential scan. `EXPLAIN ANALYZE` shows which.
How to fix Postgres Slow Query?
Run `EXPLAIN ANALYZE` on the query in production. Look for Seq Scan on large tables, missing indexes on join keys, and run `ANALYZE` if stats are stale.
Example fix from Kintify Fix
Input: Query takes 4s in production but fast in dev
Output: Run `EXPLAIN ANALYZE` on the query in production. Look for Seq Scan on large tables, missing indexes on join keys, and run `ANALYZE` if stats are stale.
Used by developers debugging real production systems