Postgres Index Tuning

Diagnose a slow Postgres query and add the right index using EXPLAIN ANALYZE.

alexngai bd96568 555 B Updated

File contents

Postgres Index Tuning

  1. Run EXPLAIN (ANALYZE, BUFFERS) on the slow query; look for Seq Scan on large tables.
  2. Identify the filtered/joined columns driving the scan.
  3. Add a targeted index (CREATE INDEX CONCURRENTLY in production to avoid locks).
  4. Re-run EXPLAIN ANALYZE and confirm the planner switched to an Index Scan.
  5. Drop indexes that never appear in pg_stat_user_indexes — they only slow writes.

alexngai/skill-tree/tree/main/docs/demo/skills/postgres-index-tuning commit bd9656838e

Frequently asked questions

npx skillmds@latest add alexngai/postgres-index-tuning