Re: Add pg_stat_autovacuum_priority
Robert Treat <rob@xzilla.net>
From: Robert Treat <rob@xzilla.net>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Sami Imseih <samimseih@gmail.com>, satyanarlapuram@gmail.com, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-03-30T12:56:12Z
Lists: pgsql-hackers
On Sun, Mar 29, 2026 at 10:09 PM Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote: > On Sat, Mar 28, 2026 at 10:54 AM Sami Imseih <samimseih@gmail.com> wrote: > > > > > 4. Is the view intended to be exposed to PUBLIC without any ACL restrictions? > > > > > 2/ Do we need to revoke permissions on pg_stat_get_autovacuum_priority > > > for all and grant them to pg_monitor or similar? Especially since this > > > function loops over all the relations in a database, we may not want > > > everyone to be able to do this. > > > > I think you're correct there. While the data is not sensitive, it > > should have more controlled usage. It's only taking an AccessShareLock, > > but you would not want anyone to be able to run this since it's > > doing real computation. I think requiring pg_read_all_stats > > is a good idea. Will do. > > +1 for pg_read_all_stats. > Is there a gap here where someone may have been granted MAINTAIN on a relation but they do not have pg_read_all_stats? > > > Can we have the per-relation prioritization computation function in C > > > and provide a per-database computation function as a SQL function over > > > this per-relation function in system_functions.sql? > > > > Yes, perhaps we should do this. So we can have a function called > > pg_stat_get_autovacuum_priority() that either takes a NULL or an OID > > to either return all the tables or just a single table. > > This is a similar usage pattern as pg_stat_get_subscription or > > pg_stat_get_activity. > > > > pg_stat_autovacuum_priority will be a view that wraps around the NULL > > variant of the function. > > > > The case where the OID is passed we just do a SearchSysCache1(RELOID,...) > > whereas the other case will do the full catalog scan. > > > > What do you think? > > IMHO, we can have pg_stat_get_relation_autovacuum_priority defined as > a C function to give the autovacuum scoring as of the given moment for > the given table. It's easy for one to write a function to get scoring > for all the relations in a database. This keeps things simple yet > useful. > I don't have a strong opinion on the above, but I do suspect that the most common way people will interact with this is by querying against the view with a WHERE clause, so optimizing for that case seems important. Robert Treat https://xzilla.net
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