Re: Add pg_stat_autovacuum_priority
Nathan Bossart <nathandbossart@gmail.com>
From: Nathan Bossart <nathandbossart@gmail.com>
To: Sami Imseih <samimseih@gmail.com>
Cc: Robert Treat <rob@xzilla.net>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, satyanarlapuram@gmail.com, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-03-31T16:28:18Z
Lists: pgsql-hackers
On Tue, Mar 31, 2026 at 11:15:35AM -0500, Sami Imseih wrote: >> + * force_scores set to true forces the computation of a score. This is useful for >> + * tools that wish to inspect scores outside of the do_vacuum() path. >> >> I'm of two minds about this new function parameter. On one hand, I see the >> utility of forcing score calculations even when autovacuum is disabled. On >> the other hand, when autovacuum is disabled, the scores are actually 0.0, >> and it's probably a good idea to report exactly what autovacuum workers >> see. > > I went back and forth on this. Showing 0.0 when autovacuum is disabled > would reflect what autovacuum workers actually see, but I think the more > useful behavior is to always compute the score based on the table's actual > state. This way, a DBA who has disabled autovacuum on a table can still > see that its score is climbing and needs attention. The view shows need, > not eligibility. This will also make the view more useful for maintenance > jobs that wish to supplement autovacuum by looking at high scores > and triggering a manual vacuum for those tables. That's a fair point. >> I also see that we're not forcing the computation of the (M)XID >> scores. Is that intentional? > > hmm, the force_score does not need to be in the force_vacuum path > because the score is calculated there naturally when the table is in > need of force_vacuum. The force_score is there to ensure that > we are not existing early in the autovacuum disabled case. So, unless the table is beyond a freeze-max-age parameter, the (M)XID scores will always be 0.0? >> I wonder if we can rework this function to always calculate the scores, >> even if autovacuum is disabled or !force_vacuum. This way, both paths are >> doing the exact same thing and reporting the same scores. > > I prefer that we still calculate the score as if autovacuum is enabled > for the reason above. I do think one potential middle ground is to have > needs_analyze, needs_vacuum, eligible_analyze, eligible_vacuum > fields to differentiate. I just rather not hide a score because a/v > is disabled on a table. My point is that instead of introducing a parameter to force score computations, we could just _always_ do that in this function. IOW maybe we could use this as an opportunity to simplify the function while also preparing it for the system view. -- nathan
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix double-free in pg_stat_autovacuum_scores.
- 71ff232a5bc4 19 (unreleased) landed
-
Add LOG_NEVER error level code.
- 60165db6e1f2 19 (unreleased) landed
-
Add pg_stat_autovacuum_scores system view.
- 87f61f0c8280 19 (unreleased) landed
-
Remove recheck_relation_needs_vacanalyze().
- 775fe51daaef 19 (unreleased) landed
-
Add elevel parameter to relation_needs_vacanalyze().
- 01876ace1369 19 (unreleased) landed
-
Teach relation_needs_vacanalyze() to always compute scores.
- 53b8ca6881a1 19 (unreleased) landed
-
Refactor relation_needs_vacanalyze().
- 8261ee24fe33 19 (unreleased) landed
-
Add rudimentary table prioritization to autovacuum.
- d7965d65fc5b 19 (unreleased) cited
-
Fix per-relation memory leakage in autovacuum.
- 02502c1bca54 18.0 cited
-
Fix recently-understood problems with handling of XID freezing, particularly
- 48188e1621bb 8.2.0 cited