Re: Disabling vacuum truncate for autovacuum

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>, Gurjeet Singh <gurjeet(at)singh(dot)im>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Postgres Hackers <pgsql-hackers(at)postgresql(dot)org>, Will Storey <will(at)summercat(dot)com>
Subject: Re: Disabling vacuum truncate for autovacuum
Date: 2025-03-05 23:54:59
Message-ID: 28773a66-fb88-41cf-a7ec-4216e6c91c94@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On 2025/03/01 3:21, Nathan Bossart wrote:
> On Thu, Feb 27, 2025 at 08:29:16PM -0800, Gurjeet Singh wrote:
>> On Mon, Jan 27, 2025 at 1:55 AM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
>>> I hope it is possible to override the global setting with the "vacuum_truncate"
>>> option on an individual table.
>>
>> Current patch behaviour is that if the autovacuum_vacuum_truncate is false, then
>> autovacuum will _not_ truncate any relations. If the parameter's value is true
>> (the default), then the relation's reloption will be honored.
>>
>> A table-owner, or the database-owner, may enable truncation of a table, as they
>> may be trying to be nice and return the unused disk space back to the
>> OS/filesystem. But if the sysadmin/DBA (who is ultimately responsible for the
>> health of the entire db instance, as well as of any replicas of the db
>> instance),
>> wants to disable truncation across all databases to ensure that the replication
>> does not get stuck, then IMHO Postgres should empower the sysadmin to make
>> that decision, and override the relation-level setting enabled by the table-
>> owner or the database-owner.
>
> IIUC reloptions with corresponding GUCs typically override the GUC setting,
> although autovacuum_enabled is arguably an exception. If setting the GUC
> to false overrides the relation-specific settings, it also becomes more
> difficult to enable truncation for just a couple of tables, although that
> might not be a popular use-case. Furthermore, even if we do want the GUC
> to override the reloption, it won't override VACUUM (TRUNCATE).

+1 to having the reloption (if specified) override the GUC setting.
That is, I think that autovacuum_vacuum_truncate as defining
the default behavior for VACUUM truncation, and that the GUC should
only apply when neither the TRUNCATE option in VACUUM nor
the reloption is set.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Igor Korot 2025-03-06 00:55:05 Re: Error on query execution
Previous Message Adrian Klaver 2025-03-05 23:49:05 Re: Duplicate Key Values

Browse pgsql-hackers by date

  From Date Subject
Next Message Shay Rojansky 2025-03-06 00:02:44 JSON_VALUE() behavior when RETURNING bytea (expected base64 decoding)
Previous Message Melanie Plageman 2025-03-05 23:40:10 Re: Log connection establishment timings