Cookbook recipe

Index bloat vs table bloat: telling them apart

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

Scenario

Storage is up but is it the table or its indexes? They bloat differently and need different fixes. Diagnose it Compare heap vs index sizes over time: SELECT pg_size_pretty(pg_relation_size('t')) AS heap, pg_size_pretty(pg_indexes_size('t')) AS idx; Why it…

Investigation Path

Storage is up but is it the table or its indexes? They bloat differently and need different fixes.

Diagnose it

Compare heap vs index sizes over time:

SELECT pg_size_pretty(pg_relation_size('t')) AS heap,
       pg_size_pretty(pg_indexes_size('t')) AS idx;

Why it happens

Table bloat comes from dead tuples VACUUM has not reclaimed (or cannot return to the OS). Index bloat comes from page splits and dead entries; b-trees do not shrink on their own and degrade with churn.

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