All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

PostgreSQL VACUUM Limitations: Why Indexes Become Bloated and How to Fix Them

By

birdculture

5mo ago· 14 min readen

Summary

This article debunks common misconceptions about PostgreSQL's VACUUM command, explaining that while VACUUM cleans dead tuples from tables, it doesn't properly clean up index bloat. The article details how B-tree indexes become fragmented over time as rows are deleted and updated, leaving behind 'dead' index entries that waste space and degrade performance. It covers the storage anatomy of PostgreSQL, the difference between table and index cleanup, and provides practical solutions for properly maintaining indexes through techniques like REINDEX, CREATE INDEX CONCURRENTLY, and pg_repack.

Key quotes

· 5 pulled
VACUUM is lying to you about your indexes
When you delete a row in PostgreSQL, it is just marked as a 'dead tuple'
B-trees fragment and how to fix them properly
Only when all transactions referencing the dead tuple are gone, VACUUM can finally remove it
The dirty secret: VACUUM doesn't clean up indexes the same way it cleans tables
Snippet from the RSS feed
PostgreSQL VACUUM cleans tables but leaves indexes bloated. Learn why B-trees fragment and how to fix them properly.

You might also wanna read