PostgreSQL B-tree vacuum leaves empty leaf pages

boringsql.com11 min read

This article explores PostgreSQL B-tree index storage internals, detailing how pages are structured, how deletions and the VACUUM process leave gaps behind, and why sequential keys prevent those gaps from being reused. The author demonstrates that VACUUM cleans dead index entries but cannot compact or merge half-empty leaf pages, meaning space is only reclaimed through page deletion of completely empty ranges or explicit index rebuilds. Open article →