Re: Add pg_stat_autovacuum_priority

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Robert Treat <rob(at)xzilla(dot)net>, satyanarlapuram(at)gmail(dot)com, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add pg_stat_autovacuum_priority
Date: 2026-04-01 21:28:45
Message-ID: ac2ODZSOjWNzueHZ@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

+ bool needs_vacuum; /* threshold exceeded for vacuum */
+ bool needs_analyze; /* threshold exceeded for analyze */
+ bool is_wraparound; /* at risk of XID/MXID wraparound */

I've been thinking about whether to also return whether autovacuum is
enabled in the view, i.e., AutoVacuumingActive() && av_enabled. My
instinct was that would help explain why autovacuum isn't picking up tables
that are eligible for autovacuum based on the view. One wrinkle is that
it'd report false even when autovacuum is working on a table for wraparound
prevention. I'm also not especially excited about further complicating
this stuff for folks who disable autovacuum. Furthermore, the value of the
reloptions and autovacuum GUC are discoverable elsewhere. So, I'm
currently leaning towards leaving that information out for now.

+ if (vactuples > vacthresh)
+ {
+ scores->needs_vacuum = true;
+ if (av_enabled && AutoVacuumingActive())
*dovacuum = true;
}

nitpick: We might be able to simplify this a bit by 1) storing "av_enabled
&& AutoVacuumingActive()" in a variable and 2) reworking the code to look
more like this:

scores->needs_vacuum = (vactuples > vacthresh);
*do_vacuum |= (av_enabled && scores->needs_vacuum);

... but others might find your version easier to read.

Otherwise, 0001 looks good.

In 0003, I think you missed renaming the last argument to
compute_autovac_score() in table_recheck_autovac().

I didn't see anything else in this read-through. I'm planning to start
preparing this for commit tomorrow.

--
nathan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniil Davydov 2026-04-01 21:43:47 Re: POC: Parallel processing of indexes in autovacuum
Previous Message Daniil Davydov 2026-04-01 21:24:29 Re: POC: Parallel processing of indexes in autovacuum