doc: fix pg_stat_autovacuum_scores threshold wording

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Subject: doc: fix pg_stat_autovacuum_scores threshold wording
Date: 2026-06-25 02:44:23
Message-ID: E3ABDC6B-80CA-4C37-BA0B-A519D49F4C66@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While testing “[d7965d65f] Add rudimentary table prioritization to autovacuum”, I noticed a small doc issue.

In monitoring.sgml, it states:
```
<row>
<entry role="catalog_table_entry"><para role="column_definition">
<structfield>vacuum_score</structfield> <type>double precision</type>
</para>
<para>
Vacuum component score. Scores greater than or equal to
<xref linkend="guc-autovacuum-vacuum-score-weight"/> indicate that
autovacuum would vacuum the table (unless autovacuum is disabled).
</para></entry>
</row>
```

This indicates that when vacuum_score >= autovacuum_vacuum_score_weight, autovacuum would vacuum the table.

However, the related code uses >, not >=:
```
/* Determine if this table needs vacuum, and update the score. */
scores->vac = (double) vactuples / Max(vacthresh, 1);
scores->vac *= autovacuum_vacuum_score_weight;
scores->max = Max(scores->max, scores->vac);
if (av_enabled && vactuples > vacthresh)
*dovacuum = true;
```

Also, see the following test:
```
evantest=# create table t (id int) with (
evantest(# autovacuum_vacuum_threshold = 1,
evantest(# autovacuum_vacuum_scale_factor = 0,
evantest(# autovacuum_analyze_threshold = 1000000);
CREATE TABLE
evantest=# insert into t values(1);
INSERT 0 1
evantest=# delete from t;
DELETE 1
evantest=# select pg_stat_force_next_flush();
pg_stat_force_next_flush
--------------------------

(1 row)
evantest=# select vacuum_score, do_vacuum from pg_stat_autovacuum_scores s where s.relid='t'::regclass;
vacuum_score | do_vacuum
--------------+-----------
1 | f
(1 row)
```
Here vacuum_score is 1, and autovacuum_vacuum_score_weight is the default 1.0 defined in postgres.conf. From the user's view they are equal, but do_vacuum is false.

The same boundary applies to the other component scores as well: the code uses strict comparisons to decide whether autovacuum would vacuum or analyze the table.

So I think we should fix the docs by changing "greater than or equal to" to "greater than". See the attached small patch.

BTW, I also noticed that the release note about this feature has a typo. I will report that to Bruce in the release note thread.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment Content-Type Size
v1-0001-Fix-pg_stat_autovacuum_scores-threshold-wording.patch application/octet-stream 3.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-06-25 02:57:47 Re: First draft of PG 19 release notes
Previous Message Kyotaro Horiguchi 2026-06-25 02:19:54 Re: uuidv7 improperly accepts dates before 1970-01-01