Cookbook recipe

What a dead tuple is and why VACUUM exists

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

Scenario

You delete a million rows but the table does not shrink. Those rows became dead tuples, and only VACUUM makes their space reusable. Diagnose it Count dead tuples on a table: SELECT relname, n_dead_tup FROM pg_stat_user_tables…

Investigation Path

You delete a million rows but the table does not shrink. Those rows became dead tuples, and only VACUUM makes their space reusable.

Diagnose it

Count dead tuples on a table:

SELECT relname, n_dead_tup FROM pg_stat_user_tables WHERE relname='orders';

Why it happens

Because of MVCC, DELETE and UPDATE do not erase data immediately — they mark the old version dead. The space is not reusable until VACUUM confirms no transaction can still see it.

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