From 127545342395820d8be0b98681a092be88bce897 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
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

