]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Allow autovacuum to use parallel vacuum workers.
authorMasahiko Sawada <msawada@postgresql.org>
Mon, 6 Apr 2026 18:48:29 +0000 (11:48 -0700)
committerMasahiko Sawada <msawada@postgresql.org>
Mon, 6 Apr 2026 18:48:29 +0000 (11:48 -0700)
commit1ff3180ca0169556984ab83759477f593129794d
treedaefb17e7e623b1c44855090078399f0e70c224d
parentc0b53ec06309f955455c7d71da277991d0da4ec0
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
24 files changed:
doc/src/sgml/config.sgml
doc/src/sgml/maintenance.sgml
doc/src/sgml/ref/create_table.sgml
doc/src/sgml/ref/vacuum.sgml
src/backend/access/common/reloptions.c
src/backend/access/heap/vacuumlazy.c
src/backend/commands/vacuum.c
src/backend/commands/vacuumparallel.c
src/backend/postmaster/autovacuum.c
src/backend/utils/init/globals.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc_parameters.dat
src/backend/utils/misc/postgresql.conf.sample
src/bin/psql/tab-complete.in.c
src/include/commands/vacuum.h
src/include/miscadmin.h
src/include/utils/rel.h
src/test/modules/Makefile
src/test/modules/meson.build
src/test/modules/test_autovacuum/.gitignore [new file with mode: 0644]
src/test/modules/test_autovacuum/Makefile [new file with mode: 0644]
src/test/modules/test_autovacuum/meson.build [new file with mode: 0644]
src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl [new file with mode: 0644]
src/tools/pgindent/typedefs.list