| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, nathandbossart(at)gmail(dot)com |
| Subject: | Re: doc: fix pg_stat_autovacuum_scores threshold wording |
| Date: | 2026-06-25 06:03:00 |
| Message-ID: | E1AF21DB-149C-46E6-9A3F-5F224E80105C@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Jun 25, 2026, at 11:45, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> wrote:
>
> Hello,
>
> At Thu, 25 Jun 2026 10:44:23 +0800, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote in
>> 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>
>> ```
>
> If I understand this correctly, aren't the *_score_weight settings
> used to prioritize candidate tables, rather than to determine whether
> a table needs vacuuming or analyzing in the first place?
>
> Regards,
>
> --
> Kyotaro Horiguchi
> NTT Open Source Software Center
Yes, I agree that the *_score_weight settings are used for prioritizing candidate tables, not for deciding eligibility directly.
I actually took time to try to understand where the current wording may have come from. For example, for vacuum_score, the code does:
```
/* 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;
```
So, dovacuum is determined by "vactuples > vacthresh", in other words, when vactuples / vacthresh > 1, dovacuum is true. Let’s ignore av_enabled here.
Then, the score is computed roughly as
```
scores->vac = (vactuples / vacthresh) * autovacuum_vacuum_score_weight
```
So when (vactuples / vacthresh) > 1, the score > autovacuum_vacuum_score_weight.
I guess that may be how the current wording came from. But it seems a bit indirect to describe it that way, because the weight itself does not determine if autovacuum would vacuum or analyze the table.
Rewriting the doc more broadly would be a larger change. This small patch is only meant to avoid the confusion shown by the test earlier, where the score is equal to the weight but do_vacuum is false.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Imran Zaheer | 2026-06-25 06:06:02 | Re: Move system identifier generation to a common helper |
| Previous Message | Peter Smith | 2026-06-25 05:57:46 | Re: Include sequences in publications created by pg_createsubscriber |