From: Nathan Bossart <nathandbossart@gmail.com>
To: Sami Imseih <samimseih@gmail.com>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Robert Treat <rob@xzilla.net>
Cc: satyanarlapuram@gmail.com, pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: remove autoanalyze corner case
Date: Fri, 3 Apr 2026 21:55:25 -0500
Message-ID: <adB9nSsm_S0D9708@nathan> (raw)
(new thread from [0])
On Fri, Apr 03, 2026 at 02:13:16PM -0500, Sami Imseih wrote:
>> * I noticed that if autovacuum decides to force a vacuum for
>> anti-wraparound purposes, it might also decide to analyze the table even if
>> autovacuum is disabled for it. AFAICT this is accidental, but since it's
>> behaved this way since commit 48188e1621 (2006) [0], I am slightly worried
>> that this bug may have become a feature. In 0002, I separated this edge
>> case in the code and added a comment, and I intend to start a new thread
>> about removing it.
>
> hmm yeah, I think this just needs to be documented clearly. I always
> thought it was expected for auto-analyze to run in this case, and I don't
> see why it shouldn't. If this needs to be clarified in docs, we should
> do that in a separate discussion.
Well, autoanalyze only runs in this case if autovacuum is disabled via the
table's autovacuum_enabled reloption and _not_ disabled via the autovacuum
or track_counts GUCs. I think this is pretty clearly unintentional, as I
can find no mention in the code, archives, or docs. And unless I'm missing
something, it's completely unnecessary. So IMHO we should just remove it.
[0] https://postgr.es/m/CAA5RZ0sCRjH3xkHFdSXnKysdMZXFyaS_094%2BK-O_rr4Fkmwc%3DQ%40mail.gmail.com
--
nathan
From e816e479836a8d10dffade409d02cbd843bd34f1 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 3 Apr 2026 21:49:24 -0500
Subject: [PATCH v1 1/1] remove autoanalyze corner case
---
src/backend/postmaster/autovacuum.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.cindex 8400e6722cc..857e44034d9 100644--- a/src/backend/postmaster/autovacuum.c+++ b/src/backend/postmaster/autovacuum.c@@ -3329,15 +3329,6 @@ relation_needs_vacanalyze(Oid relid,
scores->max = Max(scores->max, scores->anl);
if (av_enabled && anltuples > anlthresh)
*doanalyze = true;
-- /*- * For historical reasons, we analyze even when autovacuum is disabled- * for the table if at risk of wraparound. It's not clear if this is- * intentional, but it has been this way for a very long time, so it- * seems best to avoid changing it without further discussion.- */- if (force_vacuum && AutoVacuumingActive() && anltuples > anlthresh)- *doanalyze = true;
}
if (vac_ins_base_thresh >= 0)
--
2.50.1 (Apple Git-155)
Attachments:
[text/plain] v1-0001-remove-autoanalyze-corner-case.patch (1.1K, ../adB9nSsm_S0D9708@nathan/2-v1-0001-remove-autoanalyze-corner-case.patch)
download | inline diff:
From e816e479836a8d10dffade409d02cbd843bd34f1 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 3 Apr 2026 21:49:24 -0500
Subject: [PATCH v1 1/1] remove autoanalyze corner case
---
src/backend/postmaster/autovacuum.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.cindex 8400e6722cc..857e44034d9 100644--- a/src/backend/postmaster/autovacuum.c+++ b/src/backend/postmaster/autovacuum.c@@ -3329,15 +3329,6 @@ relation_needs_vacanalyze(Oid relid,
scores->max = Max(scores->max, scores->anl);
if (av_enabled && anltuples > anlthresh)
*doanalyze = true;
-- /*- * For historical reasons, we analyze even when autovacuum is disabled- * for the table if at risk of wraparound. It's not clear if this is- * intentional, but it has been this way for a very long time, so it- * seems best to avoid changing it without further discussion.- */- if (force_vacuum && AutoVacuumingActive() && anltuples > anlthresh)- *doanalyze = true;
}
if (vac_ins_base_thresh >= 0)
--
2.50.1 (Apple Git-155)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: nathandbossart@gmail.com, samimseih@gmail.com, bharath.rupireddyforpostgres@gmail.com, rob@xzilla.net
Subject: Re: remove autoanalyze corner case
In-Reply-To: <adB9nSsm_S0D9708@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox