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/
v1-0001-Fix-pg_stat_autovacuum_scores-threshold-wording.patch
Description: Binary data
