Subject: remove autoanalyze corner case

From: Nathan Bossart <[email-masked]>
Date: Fri, 3 Apr 2026 21:55:25 -0500

(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: Robert Treat <[email-masked]>
Date: Sat, 4 Apr 2026 07:53:21 -0400

> [0] https://postgr.es/m/CAA5RZ0sCRjH3xkHFdSXnKysdMZXFyaS_094%2BK-O_rr4Fkmwc%3DQ%40mail.gmail.com

AFAICS, near misses on wraparound in and of itself have no correlation
with statistical changes in your data, so I'd agree it isn't
necessary, and the fact that it behaves differently in this more
narrow case than it would in the more general case, when these two
cases are (as far as I've ever known) supposed to behave the same way,
I'd be +1 to remove this.

Robert Treat
https://xzilla.net

---

From: Álvaro Herrera <[email-masked]>
Date: Sat, 4 Apr 2026 14:40:51 +0200

> I'd be +1 to remove this.

Yeah, that matches my impression.  +1 to remove it.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"La verdad no siempre es bonita, pero el hambre de ella sí"

---

From: Sami Imseih <[email-masked]>
Date: Sat, 4 Apr 2026 08:34:38 -0500

> Yeah, that matches my impression.  +1 to remove it.

That is fine with me also.

The patch LGTM.

--
Sami

---

From: Shinya Kato <[email-masked]>
Date: Sun, 5 Apr 2026 22:46:08 +0900

> 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

---

From: Sami Imseih <[email-masked]>
Date: Sun, 5 Apr 2026 17:28:06 -0500

> anti-wraparound autovacuum does not perform an ANALYZE, like in the

+1 to the additional documentation.

a small nit: We can just say "skipped" and not "still skipped".

--
Sami

---

From: Shinya Kato <[email-masked]>
Date: Mon, 6 Apr 2026 11:32:03 +0900

> a small nit: We can just say "skipped" and not "still skipped".

Thanks, I've fixed it.

-- 
Best regards,
Shinya Kato
NTT OSS Center

---

From: Nathan Bossart <[email-masked]>
Date: Mon, 6 Apr 2026 11:29:41 -0500

Committed.  I left out the documentation updates for now.

-- 
nathan

---

From: Shinya Kato <[email-masked]>
Date: Mon, 25 May 2026 17:09:13 +0900

> Committed.  I left out the documentation updates for now.

Thanks for committing! I've attached a patch with just the
documentation updates, in case it's still useful.

-- 
Best regards,
Shinya Kato
NTT OSS Center