{"Entry":{"collection":"guc","key":"vacuum_truncate","name":"vacuum_truncate","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Vacuuming / Default Behavior","category_zh":"","changed_in":[],"changes":[{"documentation_changed":false,"fields":{},"from":"17","status":"added","to":"18"}],"content_hash":"2e11a1b29e70568418e3c17aaf4895d6ad2a60c7d752c36fcc470d126558ba52","context":"","default_changed_in":[],"default_history":[{"from":"18","to":"19","value":"on"}],"editorial":{"advice":{"olap":"Run explicit ANALYZE/VACUUM after bulk loads instead of waiting only for proportional triggers; plan freezing and visibility-map advancement separately for append-only partitions.","oltp":"Tune vacuum_truncate from table size, change rate, and maintenance SLA, using per-table thresholds for large/hot relations. Observe trigger intervals, dead tuples, and ANALYZE/VACUUM duration.","small":"Start with upstream. Fixed thresholds dominate on small tables; after changes, confirm worker and I/O headroom."},"mechanism":["Enables vacuum to truncate empty pages at the end of the table. It can be changed at session scope, so different sessions may observe different behavior.","At the end of VACUUM, PostgreSQL may take an ACCESS EXCLUSIVE lock and remove wholly empty pages from the physical tail of a table. Disabling truncation avoids that lock episode but leaves the file allocated for later reuse.","Monitor and change vacuum_truncate together with vacuum_max_eager_freeze_failure_rate, vacuum_freeze_table_age, autovacuum_freeze_max_age. Validate on the relevant server role and real workload, then use its user context to choose session change, reload, or restart; a historical boot default is not the current effective value."],"pitfalls":["Assuming truncation removes empty pages in the middle of a relation; only a contiguous empty tail can be removed.","Ignoring the ACCESS EXCLUSIVE lock attempt and blocking latency on a busy table.","Disabling truncation and expecting the operating system file size to shrink anyway.","Forgetting a table-level vacuum_truncate storage parameter can override the session/global value.","Relying on truncation during wraparound failsafe, when VACUUM can skip it to finish sooner."],"references":[{"title":"PostgreSQL 19 Beta 4: vacuum_truncate","url":"https://www.postgresql.org/docs/19/runtime-config-vacuum.html#GUC-VACUUM-TRUNCATE"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["vacuum_max_eager_freeze_failure_rate","vacuum_freeze_table_age","autovacuum_freeze_max_age","maintenance_work_mem","autovacuum","autovacuum_analyze_scale_factor"],"summary":"vacuum_truncate — Enables vacuum to truncate empty pages at the end of the table. Observed in PG18–19 Beta 4; its last measured boot default is on in PG19 Beta 4, with user context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"18","group":"Vacuuming","group_slug":"vacuum","imported_at":"2026-09-27T17:57:32.308224+08:00","intro_commit":{"authored_at":"2025-03-20T10:16:50-05:00","discussion":["https://postgr.es/m/Z2DE4lDX4tHqNGZt%40dev.null"],"hash":"0164a0f9ee12e0eff9e4c661358a272ecd65c2d4","subject":"Add vacuum_truncate configuration parameter.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=0164a0f9ee12e0eff9e4c661358a272ecd65c2d4"},"key":"vacuum_truncate","last_version":"20","max_val":"","min_val":"","name":"vacuum_truncate","position":460,"present_in":["18","19","20"],"short_desc":"Enables or disables vacuum to try to truncate off any empty pages at the end of the table.","short_desc_zh":"","source_rev":"english-manuals:30d3d388f3642abbf7852e06db73a8357e3135a36639d9a6f98a7e33bb63dddd","unit":"","vartype":"bool"}},"Definition":{"Collection":"guc","Key":"vacuum_truncate","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"vacuum_truncate","SourceRevision":"english-manuals:30d3d388f3642abbf7852e06db73a8357e3135a36639d9a6f98a7e33bb63dddd","Facts":{"boot_val":"on","category":"Vacuuming / Default Behavior","context":"user","description":"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.","doc":{"anchor":"GUC-VACUUM-TRUNCATE","file":"runtime-config-vacuum.html","lang":"en","sha256":"7047f1fa9138b97f1812532f8a905fa7479451dfd64655e029a7d387b20b22e4","slug":"18"},"documented":true,"enumvals":null,"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"vacuum_truncate","short_desc":"Enables vacuum to truncate empty pages at the end of the table.","source":"pg-settings-source-snapshot","unit":null,"vartype":"bool"},"ManualEvidence":{"doc":{"anchor":"GUC-VACUUM-TRUNCATE","file":"runtime-config-vacuum.html","lang":"en","sha256":"7047f1fa9138b97f1812532f8a905fa7479451dfd64655e029a7d387b20b22e4","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"vacuum_truncate","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"vacuum_truncate","Summary":"","BodyHTML":"\u003cp\u003e启用或禁用 vacuum 尝试截断表末尾的空页。默认值为\u003ccode\u003etrue\u003c/code\u003e。如果为\u003ccode\u003etrue\u003c/code\u003e，则\u003ccode\u003eVACUUM\u003c/code\u003e和 autovacuum 会执行截断，并将这些页面占用的磁盘空间返还给操作系统。请注意，截断需要获取表上的\u003ccode\u003eACCESS EXCLUSIVE\u003c/code\u003e锁。如果在\u003ca href=\"/docs/18/sql-vacuum.html\" title=\"VACUUM\" rel=\"nofollow\"\u003e\u003ccode\u003eVACUUM\u003c/code\u003e\u003c/a\u003e中指定了\u003ccode\u003eTRUNCATE\u003c/code\u003e参数，它将覆盖该参数的值。也可以通过修改表存储参数来为单个表覆盖此设置。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"aa102988f8f7269df97bac8cd654d5d70c680dec32008700bc7ca1783e96e7d4","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e启用或禁用 vacuum 尝试截断表末尾的空页。默认值为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e。如果为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e，则\u003ccode class=\"command\"\u003eVACUUM\u003c/code\u003e和 autovacuum 会执行截断，并将这些页面占用的磁盘空间返还给操作系统。请注意，截断需要获取表上的\u003ccode class=\"literal\"\u003eACCESS EXCLUSIVE\u003c/code\u003e锁。如果在\u003ca href=\"/docs/18/sql-vacuum.html\" title=\"VACUUM\"\u003e\u003ccode class=\"command\"\u003eVACUUM\u003c/code\u003e\u003c/a\u003e中指定了\u003ccode class=\"literal\"\u003eTRUNCATE\u003c/code\u003e参数，它将覆盖该参数的值。也可以通过修改表存储参数来为单个表覆盖此设置。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
