PostgreSQL VACUUM and MVCC: why dead rows pile up
Short answer
PostgreSQL uses MVCC (multiversion concurrency control): an UPDATE or DELETE leaves the old row version in place so other transactions can still see it. VACUUM cleans them. [S1][S2]
What VACUUM does
- Recovers or reuses space from updated or deleted rows. [S1]
- Updates planner statistics and the visibility map (which speeds up index-only scans). [S1]
- To protect against loss of very old data due to transaction ID wraparound or multixact ID wraparound. (S1)
If you have a table whose entire contents are deleted on a periodic basis, consider doing it with TRUNCATE rather than using DELETE followed by VACUUM. (S1)
Claims
- id: C1 claim: VACUUM recovers or reuses disk space from updated or deleted rows. source: S1 evidence: "To recover or reuse disk space occupied by updated or deleted rows."
- id: C2 claim: VACUUM updates the visibility map for index-only scans. source: S1 evidence: "To update the visibility map, which speeds up index-only scans."
- id: C3 claim: VACUUM protects against transaction ID wraparound data loss. source: S1 evidence: "To protect against loss of very old data due to transaction ID wraparound"
- id: C4 claim: Under MVCC reading never blocks writing. source: S2 evidence: "reading never blocks writing and writing never blocks"
Sources
- [S1] PostgreSQL: Documentation: 18: 24.1. Routine Vacuuming. PostgreSQL Global Development Group. https://www.postgresql.org/docs/current/routine-vacuuming.html . License: PostgreSQL License. Accessed 2026-11-04.
- [S2] PostgreSQL: Documentation: 18: 13.1. Introduction. PostgreSQL Global Development Group. https://www.postgresql.org/docs/current/mvcc-intro.html . License: PostgreSQL License. Accessed 2026-11-04.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: 24.1. Routine Vacuuming, PostgreSQL License; PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: 13.1. Introduction, PostgreSQL License.
Cite this
iinventedlight. 2026. "PostgreSQL VACUUM and MVCC: why dead rows pile up." iinventedlight Library, iil:note:ewke3cyc, version of 2026-11-04. https://iinventedlight.com/library/notes/postgres-vacuum-mvcc/. License: CC-BY-4.0.
@misc{iil_note_ewke3cyc,
author = {{iinventedlight}},
title = {{PostgreSQL VACUUM and MVCC: why dead rows pile up}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-04},
url = {https://iinventedlight.com/library/notes/postgres-vacuum-mvcc/},
note = {Permanent ID iil:note:ewke3cyc. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/postgres-vacuum-mvcc.md.