diff options
author | Nathan Bossart <nathan@postgresql.org> | 2025-03-20 10:16:50 -0500 |
---|---|---|
committer | Nathan Bossart <nathan@postgresql.org> | 2025-03-20 10:16:50 -0500 |
commit | 0164a0f9ee12e0eff9e4c661358a272ecd65c2d4 (patch) | |
tree | adc03a29d38053e20cf598d579a8717f16b21212 /doc/src | |
parent | 618c64ffd3967cb5313b4b11e1e1043a074f2139 (diff) | |
download | postgresql-0164a0f9ee12e0eff9e4c661358a272ecd65c2d4.tar.gz postgresql-0164a0f9ee12e0eff9e4c661358a272ecd65c2d4.zip |
Add vacuum_truncate configuration parameter.
This new parameter works just like the storage parameter of the
same name: if set to true (which is the default), autovacuum and
VACUUM attempt to truncate any empty pages at the end of the table.
It is primarily intended to help users avoid locking issues on hot
standbys. The setting can be overridden with the storage parameter
or VACUUM's TRUNCATE option.
Since there's presently no way to determine whether a Boolean
storage parameter is explicitly set or has just picked up the
default value, this commit also introduces an isset_offset member
to relopt_parse_elt.
Suggested-by: Will Storey <will@summercat.com>
Author: Nathan Bossart <nathandbossart@gmail.com>
Co-authored-by: Gurjeet Singh <gurjeet@singh.im>
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Robert Treat <rob@xzilla.net>
Discussion: https://postgr.es/m/Z2DE4lDX4tHqNGZt%40dev.null
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/config.sgml | 29 | ||||
-rw-r--r-- | doc/src/sgml/ref/create_table.sgml | 13 | ||||
-rw-r--r-- | doc/src/sgml/ref/vacuum.sgml | 3 |
3 files changed, 35 insertions, 10 deletions
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 873290daa61..bdcefa8140b 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -9311,6 +9311,35 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; </note> </sect2> + <sect2 id="runtime-config-vacuum-default"> + <title>Default Behavior</title> + + <variablelist> + <varlistentry id="guc-vacuum-truncate" xreflabel="vacuum_truncate"> + <term><varname>vacuum_truncate</varname> (<type>boolean</type>) + <indexterm> + <primary><varname>vacuum_truncate</varname> configuration parameter</primary> + </indexterm> + </term> + <listitem> + <para> + Enables or disables vacuum to try to truncate off any empty pages at + the end of the table. The default value is <literal>true</literal>. + If <literal>true</literal>, <command>VACUUM</command> 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 <literal>ACCESS EXCLUSIVE</literal> lock on the table. The + <literal>TRUNCATE</literal> parameter of + <link linkend="sql-vacuum"><command>VACUUM</command></link>, if + specified, overrides the value of this parameter. The setting can + also be overridden for individual tables by changing table storage + parameters. + </para> + </listitem> + </varlistentry> + </variablelist> + </sect2> + <sect2 id="runtime-config-vacuum-freezing"> <title>Freezing</title> diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 5304b738322..e5c034d724e 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1692,15 +1692,10 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM </term> <listitem> <para> - Enables or disables vacuum to try to truncate off any empty pages - at the end of this table. The default value is <literal>true</literal>. - If <literal>true</literal>, <command>VACUUM</command> and - autovacuum do the truncation and the disk space for - the truncated pages is returned to the operating system. - Note that the truncation requires <literal>ACCESS EXCLUSIVE</literal> - lock on the table. The <literal>TRUNCATE</literal> parameter - of <link linkend="sql-vacuum"><command>VACUUM</command></link>, if specified, overrides the value - of this option. + Per-table value for <xref linkend="guc-vacuum-truncate"/> parameter. The + <literal>TRUNCATE</literal> parameter of + <link linkend="sql-vacuum"><command>VACUUM</command></link>, if + specified, overrides the value of this option. </para> </listitem> </varlistentry> diff --git a/doc/src/sgml/ref/vacuum.sgml b/doc/src/sgml/ref/vacuum.sgml index 971b1237d47..bd5dcaf86a5 100644 --- a/doc/src/sgml/ref/vacuum.sgml +++ b/doc/src/sgml/ref/vacuum.sgml @@ -265,7 +265,8 @@ VACUUM [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] [ <re truncate off any empty pages at the end of the table and allow the disk space for the truncated pages to be returned to the operating system. This is normally the desired behavior - and is the default unless the <literal>vacuum_truncate</literal> + and is the default unless <xref linkend="guc-vacuum-truncate"/> + is set to false or the <literal>vacuum_truncate</literal> option has been set to false for the table to be vacuumed. Setting this option to false may be useful to avoid <literal>ACCESS EXCLUSIVE</literal> lock on the table that |