public inbox for [email protected]
help / color / mirror / Atom feed[PATCH v1 1/1] remove autoanalyze corner case
16+ messages / 6 participants
[nested] [flat]
* [PATCH v1 1/1] remove autoanalyze corner case
@ 2026-04-04 02:49 Nathan Bossart <[email protected]>
0 siblings, 0 replies; 16+ messages in thread
From: Nathan Bossart @ 2026-04-04 02:49 UTC (permalink / raw)
---
src/backend/postmaster/autovacuum.c | 9 ---------
1 file changed, 9 deletions(-)
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.50.1 (Apple Git-155)
--7UU721Dt33Uo3+cq--
^ permalink raw reply [nested|flat] 16+ messages in thread
* [PATCH v1 1/1] remove autoanalyze corner case
@ 2026-04-04 02:49 Nathan Bossart <[email protected]>
0 siblings, 0 replies; 16+ messages in thread
From: Nathan Bossart @ 2026-04-04 02:49 UTC (permalink / raw)
---
src/backend/postmaster/autovacuum.c | 9 ---------
1 file changed, 9 deletions(-)
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.50.1 (Apple Git-155)
--7UU721Dt33Uo3+cq--
^ permalink raw reply [nested|flat] 16+ messages in thread
* [PATCH v1 1/1] remove autoanalyze corner case
@ 2026-04-04 02:49 Nathan Bossart <[email protected]>
0 siblings, 0 replies; 16+ messages in thread
From: Nathan Bossart @ 2026-04-04 02:49 UTC (permalink / raw)
---
src/backend/postmaster/autovacuum.c | 9 ---------
1 file changed, 9 deletions(-)
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.50.1 (Apple Git-155)
--7UU721Dt33Uo3+cq--
^ permalink raw reply [nested|flat] 16+ messages in thread
* [PATCH v1 1/1] remove autoanalyze corner case
@ 2026-04-04 02:49 Nathan Bossart <[email protected]>
0 siblings, 0 replies; 16+ messages in thread
From: Nathan Bossart @ 2026-04-04 02:49 UTC (permalink / raw)
---
src/backend/postmaster/autovacuum.c | 9 ---------
1 file changed, 9 deletions(-)
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.50.1 (Apple Git-155)
--7UU721Dt33Uo3+cq--
^ permalink raw reply [nested|flat] 16+ messages in thread
* [PATCH v1 1/1] remove autoanalyze corner case
@ 2026-04-04 02:49 Nathan Bossart <[email protected]>
0 siblings, 0 replies; 16+ messages in thread
From: Nathan Bossart @ 2026-04-04 02:49 UTC (permalink / raw)
---
src/backend/postmaster/autovacuum.c | 9 ---------
1 file changed, 9 deletions(-)
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.50.1 (Apple Git-155)
--7UU721Dt33Uo3+cq--
^ permalink raw reply [nested|flat] 16+ messages in thread
* [PATCH v1 1/1] remove autoanalyze corner case
@ 2026-04-04 02:49 Nathan Bossart <[email protected]>
0 siblings, 0 replies; 16+ messages in thread
From: Nathan Bossart @ 2026-04-04 02:49 UTC (permalink / raw)
---
src/backend/postmaster/autovacuum.c | 9 ---------
1 file changed, 9 deletions(-)
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.50.1 (Apple Git-155)
--7UU721Dt33Uo3+cq--
^ permalink raw reply [nested|flat] 16+ messages in thread
* [PATCH v1 1/1] remove autoanalyze corner case
@ 2026-04-04 02:49 Nathan Bossart <[email protected]>
0 siblings, 0 replies; 16+ messages in thread
From: Nathan Bossart @ 2026-04-04 02:49 UTC (permalink / raw)
---
src/backend/postmaster/autovacuum.c | 9 ---------
1 file changed, 9 deletions(-)
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.50.1 (Apple Git-155)
--7UU721Dt33Uo3+cq--
^ permalink raw reply [nested|flat] 16+ messages in thread
* remove autoanalyze corner case
@ 2026-04-04 02:55 Nathan Bossart <[email protected]>
0 siblings, 2 replies; 16+ messages in thread
From: Nathan Bossart @ 2026-04-04 02:55 UTC (permalink / raw)
To: Sami Imseih <[email protected]>; +Cc: Bharath Rupireddy <[email protected]>; Robert Treat <[email protected]>; [email protected]; pgsql-hackers
(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
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: remove autoanalyze corner case
@ 2026-04-04 11:53 Robert Treat <[email protected]>
parent: Nathan Bossart <[email protected]>
1 sibling, 1 reply; 16+ messages in thread
From: Robert Treat @ 2026-04-04 11:53 UTC (permalink / raw)
To: Nathan Bossart <[email protected]>; +Cc: Sami Imseih <[email protected]>; Bharath Rupireddy <[email protected]>; [email protected]; pgsql-hackers
On Fri, Apr 3, 2026 at 10:55 PM Nathan Bossart <[email protected]> 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] 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
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: remove autoanalyze corner case
@ 2026-04-04 12:40 Álvaro Herrera <[email protected]>
parent: Robert Treat <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: Álvaro Herrera @ 2026-04-04 12:40 UTC (permalink / raw)
To: Robert Treat <[email protected]>; +Cc: Nathan Bossart <[email protected]>; Sami Imseih <[email protected]>; Bharath Rupireddy <[email protected]>; [email protected]; pgsql-hackers
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í"
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: remove autoanalyze corner case
@ 2026-04-04 13:34 Sami Imseih <[email protected]>
parent: Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 16+ messages in thread
From: Sami Imseih @ 2026-04-04 13:34 UTC (permalink / raw)
To: Álvaro Herrera <[email protected]>; +Cc: Robert Treat <[email protected]>; Nathan Bossart <[email protected]>; Bharath Rupireddy <[email protected]>; [email protected]; pgsql-hackers
>> 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
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: remove autoanalyze corner case
@ 2026-04-05 13:46 Shinya Kato <[email protected]>
parent: Nathan Bossart <[email protected]>
1 sibling, 1 reply; 16+ messages in thread
From: Shinya Kato @ 2026-04-05 13:46 UTC (permalink / raw)
To: Nathan Bossart <[email protected]>; +Cc: Sami Imseih <[email protected]>; Bharath Rupireddy <[email protected]>; Robert Treat <[email protected]>; [email protected]; pgsql-hackers
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
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: remove autoanalyze corner case
@ 2026-04-05 22:28 Sami Imseih <[email protected]>
parent: Shinya Kato <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: Sami Imseih @ 2026-04-05 22:28 UTC (permalink / raw)
To: Shinya Kato <[email protected]>; +Cc: Nathan Bossart <[email protected]>; Bharath Rupireddy <[email protected]>; Robert Treat <[email protected]>; [email protected]; pgsql-hackers
> > 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
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: remove autoanalyze corner case
@ 2026-04-06 02:32 Shinya Kato <[email protected]>
parent: Sami Imseih <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: Shinya Kato @ 2026-04-06 02:32 UTC (permalink / raw)
To: Sami Imseih <[email protected]>; +Cc: Nathan Bossart <[email protected]>; Bharath Rupireddy <[email protected]>; Robert Treat <[email protected]>; [email protected]; pgsql-hackers
On Mon, Apr 6, 2026 at 7:28 AM Sami Imseih <[email protected]> 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:
[application/octet-stream] v3-0001-remove-autoanalyze-corner-case.patch (2.8K, 2-v3-0001-remove-autoanalyze-corner-case.patch)
download | inline diff:
From 402f87eef7d3fca4eda05cd5687fb10d589773e7 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <[email protected]>
Date: Fri, 3 Apr 2026 21:49:24 -0500
Subject: [PATCH v3] 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..412d41c637c 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 skipped.)
</para>
<para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 80829b23945..5a1c460bd97 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 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
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: remove autoanalyze corner case
@ 2026-04-06 16:29 Nathan Bossart <[email protected]>
parent: Shinya Kato <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: Nathan Bossart @ 2026-04-06 16:29 UTC (permalink / raw)
To: Shinya Kato <[email protected]>; +Cc: Sami Imseih <[email protected]>; Bharath Rupireddy <[email protected]>; Robert Treat <[email protected]>; [email protected]; pgsql-hackers
Committed. I left out the documentation updates for now.
--
nathan
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: remove autoanalyze corner case
@ 2026-05-25 08:09 Shinya Kato <[email protected]>
parent: Nathan Bossart <[email protected]>
0 siblings, 0 replies; 16+ messages in thread
From: Shinya Kato @ 2026-05-25 08:09 UTC (permalink / raw)
To: Nathan Bossart <[email protected]>; +Cc: Sami Imseih <[email protected]>; Bharath Rupireddy <[email protected]>; Robert Treat <[email protected]>; [email protected]; pgsql-hackers
On Tue, Apr 7, 2026 at 1:29 AM Nathan Bossart <[email protected]> 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
Attachments:
[application/octet-stream] v4-0001-doc-Note-that-anti-wraparound-autovacuum-skips-AN.patch (2.6K, 2-v4-0001-doc-Note-that-anti-wraparound-autovacuum-skips-AN.patch)
download | inline diff:
From 3b1599340727de0beb0d2a80d4fa7826c1f7d1da Mon Sep 17 00:00:00 2001
From: Shinya Kato <[email protected]>
Date: Mon, 25 May 2026 17:05:50 +0900
Subject: [PATCH v4] doc: Note that anti-wraparound autovacuum skips ANALYZE
Commit e3481edfd1b removed a corner case in which autoanalyze could
run on a table whose autovacuum_enabled reloption is false when an
anti-wraparound vacuum was forced. As a result, a table for which
autovacuum is disabled is now only ever VACUUMed, never ANALYZEd, by
such forced runs.
Document this behavior so it is explicit, both in the routine
vacuuming discussion and in the description of the
autovacuum_enabled storage parameter.
Author: Shinya Kato <[email protected]>
Reviewed-by: Sami Imseih <[email protected]>
Discussion: https://postgr.es/m/CAOzEurT6RJdEErH9%3D8jugMy5UMak1ZPJdY4xQ1pWS4VDwuoraQ%40mail.gmail.com
---
doc/src/sgml/maintenance.sgml | 3 ++-
doc/src/sgml/ref/create_table.sgml | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index 4a21bdb5de7..896e1387bc3 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 skipped.)
</para>
<para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index e342585c7f0..95a23ccb0b9 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 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"/>
--
2.47.3
^ permalink raw reply [nested|flat] 16+ messages in thread
end of thread, other threads:[~2026-05-25 08:09 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-04-04 02:49 [PATCH v1 1/1] remove autoanalyze corner case Nathan Bossart <[email protected]>
2026-04-04 02:49 [PATCH v1 1/1] remove autoanalyze corner case Nathan Bossart <[email protected]>
2026-04-04 02:49 [PATCH v1 1/1] remove autoanalyze corner case Nathan Bossart <[email protected]>
2026-04-04 02:49 [PATCH v1 1/1] remove autoanalyze corner case Nathan Bossart <[email protected]>
2026-04-04 02:49 [PATCH v1 1/1] remove autoanalyze corner case Nathan Bossart <[email protected]>
2026-04-04 02:49 [PATCH v1 1/1] remove autoanalyze corner case Nathan Bossart <[email protected]>
2026-04-04 02:49 [PATCH v1 1/1] remove autoanalyze corner case Nathan Bossart <[email protected]>
2026-04-04 02:55 remove autoanalyze corner case Nathan Bossart <[email protected]>
2026-04-04 11:53 ` Robert Treat <[email protected]>
2026-04-04 12:40 ` Álvaro Herrera <[email protected]>
2026-04-04 13:34 ` Sami Imseih <[email protected]>
2026-04-05 13:46 ` Shinya Kato <[email protected]>
2026-04-05 22:28 ` Sami Imseih <[email protected]>
2026-04-06 02:32 ` Shinya Kato <[email protected]>
2026-04-06 16:29 ` Nathan Bossart <[email protected]>
2026-05-25 08:09 ` Shinya Kato <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox