public inbox for [email protected]  
help / color / mirror / Atom feed
From: Shinya Kato <[email protected]>
To: Nathan Bossart <[email protected]>
Cc: Sami Imseih <[email protected]>
Cc: Bharath Rupireddy <[email protected]>
Cc: Robert Treat <[email protected]>
Cc: [email protected]
Cc: pgsql-hackers <[email protected]>
Subject: Re: remove autoanalyze corner case
Date: Sun, 5 Apr 2026 22:46:08 +0900
Message-ID: <CAOzEurT6RJdEErH9=8jugMy5UMak1ZPJdY4xQ1pWS4VDwuoraQ@mail.gmail.com> (raw)
In-Reply-To: <adB9nSsm_S0D9708@nathan>
References: <adB9nSsm_S0D9708@nathan>

On Sat, Apr 4, 2026 at 11:55 AM Nathan Bossart <[email protected]> wrote:
> 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.

+1. I think it might be better to mention this in the documentation to
make the behavior explicit. What do you think about stating that an
anti-wraparound autovacuum does not perform an ANALYZE, like in the
attached patch?



-- 
Best regards,
Shinya Kato
NTT OSS Center


Attachments:

  [application/octet-stream] v2-0001-remove-autoanalyze-corner-case.patch (2.8K, 2-v2-0001-remove-autoanalyze-corner-case.patch)
  download | inline diff:
From 127545342395820d8be0b98681a092be88bce897 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <[email protected]>
Date: Fri, 3 Apr 2026 21:49:24 -0500
Subject: [PATCH v2] remove autoanalyze corner case

---
 doc/src/sgml/maintenance.sgml       | 3 ++-
 doc/src/sgml/ref/create_table.sgml  | 4 +++-
 src/backend/postmaster/autovacuum.c | 9 ---------
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index 0d2a28207ed..7f9ad3a4867 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -531,7 +531,8 @@
     autovacuum is invoked on any table that might contain unfrozen rows with
     XIDs older than the age specified by the configuration parameter <xref
     linkend="guc-autovacuum-freeze-max-age"/>.  (This will happen even if
-    autovacuum is disabled.)
+    autovacuum is disabled.  In that case, only <command>VACUUM</command> is
+    performed; <command>ANALYZE</command> is still skipped.)
    </para>
 
    <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 80829b23945..fba0e1badbc 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -1683,7 +1683,9 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
      and/or <command>ANALYZE</command> operations on this table following the rules
      discussed in <xref linkend="autovacuum"/>.
      If false, this table will not be autovacuumed, except to prevent
-     transaction ID wraparound. See <xref linkend="vacuum-for-wraparound"/> for
+     transaction ID wraparound.  In that case, only <command>VACUUM</command>
+     is performed; <command>ANALYZE</command> is still skipped.
+     See <xref linkend="vacuum-for-wraparound"/> for
      more about wraparound prevention.
      Note that the autovacuum daemon does not run at all (except to prevent
      transaction ID wraparound) if the <xref linkend="guc-autovacuum"/>
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 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.47.3



view thread (128+ messages)  latest in thread

reply

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: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: remove autoanalyze corner case
  In-Reply-To: <CAOzEurT6RJdEErH9=8jugMy5UMak1ZPJdY4xQ1pWS4VDwuoraQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox