Parallel vacuum: workers together with leader could overrun cost budget

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Parallel vacuum: workers together with leader could overrun cost budget
Date: 2026-10-14 03:45:00
Message-ID: CALj2ACWDhGH_ACJYHvxHVbL9GZ8AgMoJFnf-u5=bWx7NZtYBRQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I noticed that the parallel workers can go over the vacuum cost
budget, with both parallel vacuum and parallel autovacuum. For
example, with the default cost delay of 2ms and cost limit of 200,
each of the 4 parallel workers and the autovacuum worker (the leader)
sleeps 2ms for every 200 cost units it incurs on its own, so each of
the 5 processes runs at the full budget. If the 200 were the budget
for the vacuum as a whole, each process would have to sleep 5 times
longer, that is 2ms per 40 cost units.

I think this is a problem, since the cost budget the user was promised
gets crossed. Please find the attached patch fixing this.

Although this exists for parallel vacuum too, back-patching it to
PG19, where parallel autovacuum was introduced, is fine, since
parallel autovacuum runs with the default cost delay and cost limit.

Thoughts?

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v1-0001-Parallel-vacuum-workers-together-with-leader-coul.patch application/octet-stream 3.5 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Manu 2026-10-14 03:59:52 Re: generic plans and "initial" pruning
Previous Message shihao zhong 2026-10-14 03:40:58 Re: [PG19] btree_gin misses rows for a timestamptz bound in the repeated DST hour