agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Masahiko Sawada <msawada@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow autovacuum to use parallel vacuum workers.
Date: Mon, 06 Apr 2026 18:49:10 +0000
Message-ID: <E1w9p0X-003HAO-3B@gemulon.postgresql.org> (raw)
Allow autovacuum to use parallel vacuum workers.
Previously, autovacuum always disabled parallel vacuum regardless of
the table's index count or configuration. This commit enables
autovacuum workers to use parallel index vacuuming and index cleanup,
using the same parallel vacuum infrastructure as manual VACUUM.
Two new configuration options control the feature. The GUC
autovacuum_max_parallel_workers sets the maximum number of parallel
workers a single autovacuum worker may launch; it defaults to 0,
preserving existing behavior unless explicitly enabled. The per-table
storage parameter autovacuum_parallel_workers provides per-table
limits. A value of 0 disables parallel vacuum for the table, a
positive value caps the worker count (still bounded by the GUC), and
-1 (the default) defers to the GUC.
To handle cases where autovacuum workers receive a SIGHUP and update
their cost-based vacuum delay parameters mid-operation, a new
propagation mechanism is added to vacuumparallel.c. The leader stores
its effective cost parameters in a DSM segment. Parallel vacuum
workers poll for changes in vacuum_delay_point(); if an update is
detected, they apply the new values locally via VacuumUpdateCosts().
A new test module, src/test/modules/test_autovacuum, is added to
verify that parallel autovacuum workers are correctly launched and
that cost-parameter updates are propagated as expected.
The patch was originally proposed by Maxim Orlov, but the
implementation has undergone significant architectural changes
since then during the review process.
Author: Daniil Davydov <3danissimo@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: zengman <zengman@halodbtech.com>
Discussion: https://postgr.es/m/CACG=ezZOrNsuLoETLD1gAswZMuH2nGGq7Ogcc0QOE5hhWaw=cw@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/1ff3180ca0169556984ab83759477f593129794d
Modified Files
--------------
doc/src/sgml/config.sgml | 24 +++
doc/src/sgml/maintenance.sgml | 34 +++
doc/src/sgml/ref/create_table.sgml | 16 ++
doc/src/sgml/ref/vacuum.sgml | 23 +--
src/backend/access/common/reloptions.c | 11 +
src/backend/access/heap/vacuumlazy.c | 12 ++
src/backend/commands/vacuum.c | 22 +-
src/backend/commands/vacuumparallel.c | 227 ++++++++++++++++++++-
src/backend/postmaster/autovacuum.c | 25 ++-
src/backend/utils/init/globals.c | 1 +
src/backend/utils/misc/guc.c | 10 +-
src/backend/utils/misc/guc_parameters.dat | 8 +
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/bin/psql/tab-complete.in.c | 1 +
src/include/commands/vacuum.h | 2 +
src/include/miscadmin.h | 1 +
src/include/utils/rel.h | 2 +
src/test/modules/Makefile | 1 +
src/test/modules/meson.build | 1 +
src/test/modules/test_autovacuum/.gitignore | 2 +
src/test/modules/test_autovacuum/Makefile | 20 ++
src/test/modules/test_autovacuum/meson.build | 15 ++
.../test_autovacuum/t/001_parallel_autovacuum.pl | 189 +++++++++++++++++
src/tools/pgindent/typedefs.list | 1 +
24 files changed, 616 insertions(+), 33 deletions(-)
view thread (5+ messages) latest in thread
Message-ID: <E1w9p0X-003HAO-3B@gemulon.postgresql.org>
Permalink: ../E1w9p0X-003HAO-3B@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1w9p0X-003HAO-3B@gemulon.postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: msawada@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Allow autovacuum to use parallel vacuum workers.
In-Reply-To: <E1w9p0X-003HAO-3B@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox