remove autoanalyze corner case
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t139214psql -h localhost -U postgresBuilt from patchset v9 (message #9), August 25, 2026 at 02:07 PM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t139214_9 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t139214_9 && git checkout t139214_9Patchset v9 (message #9) is on t139214_9
(new thread from [0]/messages/by-id/CAA5RZ0sCRjH3xkHFdSXnKysdMZXFyaS_094+K-O_rr4Fkmwc=Q@mail.gmail.com)
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]: /messages/by-id/CAA5RZ0sCRjH3xkHFdSXnKysdMZXFyaS_094+K-O_rr4Fkmwc=Q@mail.gmail.com
--
nathan
Attachments:
v1-0001-remove-autoanalyze-corner-case.patchtext/plain; charset=us-asciiDownload+0-10
On Fri, Apr 3, 2026 at 10:55 PM Nathan Bossart <nathandbossart@gmail.com> wrote:
(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] /messages/by-id/CAA5RZ0sCRjH3xkHFdSXnKysdMZXFyaS_094+K-O_rr4Fkmwc=Q@mail.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
On 2026-Apr-04, Robert Treat wrote:
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.
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í"
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.
Yeah, that matches my impression. +1 to remove it.
That is fine with me also.
The patch LGTM.
--
Sami
On Sat, Apr 4, 2026 at 11:55 AM Nathan Bossart <nathandbossart@gmail.com> 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:
v2-0001-remove-autoanalyze-corner-case.patchapplication/octet-stream; name=v2-0001-remove-autoanalyze-corner-case.patchDownload+5-12
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?
+1 to the additional documentation.
a small nit: We can just say "skipped" and not "still skipped".
--
Sami
On Mon, Apr 6, 2026 at 7:28 AM Sami Imseih <samimseih@gmail.com> wrote:
+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?+1 to the additional documentation.
a small nit: We can just say "skipped" and not "still skipped".
Thanks, I've fixed it.
--
Best regards,
Shinya Kato
NTT OSS Center
Attachments:
v3-0001-remove-autoanalyze-corner-case.patchapplication/octet-stream; name=v3-0001-remove-autoanalyze-corner-case.patchDownload+5-12
Committed. I left out the documentation updates for now.
--
nathan
On Tue, Apr 7, 2026 at 1:29 AM Nathan Bossart <nathandbossart@gmail.com> wrote:
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