Re: Introduce some randomness to autovacuum - Mailing list pgsql-hackers

From Junwang Zhao
Subject Re: Introduce some randomness to autovacuum
Date
Msg-id CAEG8a3LvTV4fRcckidTd21Tjm3JHzZHUn97vbP9z817-T8JZ=Q@mail.gmail.com
Whole thread Raw
In response to Re: Introduce some randomness to autovacuum  (Nikita Malakhov <hukutoc@gmail.com>)
Responses Re: Introduce some randomness to autovacuum
List pgsql-hackers
Hi Nikita, wenhui,

On Fri, Apr 25, 2025 at 11:16 PM Nikita Malakhov <hukutoc@gmail.com> wrote:
>
> Hi!
>
> I agree it is a good idea to shift the table list. Although vacuuming larger tables first
> is a questionable approach because smaller ones could wait a long time to be vacuumed.
> It looks like the most obvious and simple way is that the first table to be vacuumed
> should not be the first one from the previous iteration.
>
> On Fri, Apr 25, 2025 at 6:04 PM wenhui qiu <qiuwenhuifx@gmail.com> wrote:
>>
>> Hi,I like your idea,It would be even better if the weights could be taken according to the larger tables
>>
>
> --
> Regards,
> Nikita Malakhov
> Postgres Professional
> The Russian Postgres Company
> https://postgrespro.ru/


Thanks for your feedback.

I ended up with adding a guc configuration that may support different vacuum
strategies. I name it as `autovacuum_vacuum_strategy` but you might have
a better one. For now it support only two strategies:

1. Sequential: Tables are vacuumed in the order they are collected.
2. Random: The list of tables is rotated around a randomly chosen
       pivot before vacuuming to avoid always starting with the same
       table, which prevents vacuuming starvation for some tables.

We can extend this strategy like prioritization and whatever algorithms
in the future.

--
Regards
Junwang Zhao

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Accounting for metapages in genericcostestimate()
Next
From: Álvaro Herrera
Date:
Subject: Re: alphabetize long options in pg_dump[all] docs