Enables or disables vacuum to try to truncate off any empty pages at the end of the table.
At a glance
| Property | Value |
|---|---|
| Parameter | vacuum_truncate |
| Category | Vacuuming |
| Default | true |
| Value type | boolean (on/off) |
| Change scope | Per-session (SET) |
| Available in | PostgreSQL 18, 19 (added in 18) |
What it does
Enables or disables vacuum to try to truncate off any empty pages at the end of the table. The default value is true. If true, VACUUM and autovacuum do the truncation and the disk space for the truncated pages is returned to the operating system. Note that the truncation requires an ACCESS EXCLUSIVE lock on the table. The TRUNCATE parameter of VACUUM, if specified, overrides the value of this parameter. The setting can also be overridden for individual tables by changing table storage parameters.
(Description quoted from the official PostgreSQL documentation.)
How to apply a change
Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.
Inspect the current value and source with SHOW vacuum_truncate; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'vacuum_truncate';.
Tuning guidance
Leave it on so vacuum returns trailing empty pages to the OS; turn it off (globally or per-table) to avoid the brief ACCESS EXCLUSIVE lock truncation needs on hot tables.