6. VACUUM Processing

VACUUM is a maintenance process that ensures the long-term reliable operation of PostgreSQL. Its two main tasks are removing dead tuples and freezing transaction IDs. Section 5.10 briefly mentions both tasks.

Although vacuum processing is essential for PostgreSQL, its functionality improved slowly compared to other features. For example, until version 8.0, users had to execute this process manually using the psql utility or the cron daemon. Automation occurred in 2005 with the implementation of the autovacuum daemon.

Because vacuum processing scans entire tables, it is a costly process. In version 8.4 (2009), PostgreSQL introduced the Visibility Map (VM) to improve the efficiency of dead tuple removal. In version 9.6 (2016), an enhanced VM further improved the freeze process.

VACUUM removes dead tuples and prevents transaction ID wraparound. However, it cannot reclaim disk space caused by table bloat, except in the special case described in Section 6.1.3.

Until version 18, PostgreSQL addressed table bloat by reconstructing relation files using either the CLUSTER command or VACUUM FULL. Version 19 (2026) introduced the REPACK command, which serves as the common implementation for relation reconstruction. It also provides a CONCURRENTLY mode for higher online availability.

This chapter explains VACUUM processing in detail. In addition, Section 6.5 describes autovacuum, and Section 6.6 describes relation reconstruction commands.