Cookbook recipe

Track table and index bloat

Applies to PostgreSQL 13–17 Last reviewed May 2026 Grounded in source
Estimated investigation4 min

Scenario

Storage keeps growing faster than your data. You need a repeatable way to estimate bloat and decide what to repack. Diagnose it Quick dead-tuple ratio per table: SELECT relname, n_dead_tup, n_live_tup, round(100*n_dead_tup/greatest(n_live_tup,1),1) AS dead_pct FROM pg_stat_user_tables…

Investigation Path

Storage keeps growing faster than your data. You need a repeatable way to estimate bloat and decide what to repack.

Diagnose it

Quick dead-tuple ratio per table:

SELECT relname,
  n_dead_tup, n_live_tup,
  round(100*n_dead_tup/greatest(n_live_tup,1),1) AS dead_pct
FROM pg_stat_user_tables
ORDER BY n_dead_tup DESC LIMIT 20;

Why it happens

Updates and deletes leave dead tuples that VACUUM reclaims as reusable space but does not return to the OS. A high dead-tuple ratio or oversized relation vs live rows signals bloat.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • How to fix it
  • Prevent it next time
  • Related & next steps
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes