pgsql: Allow vacuum command to process indexes in parallel.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow vacuum command to process indexes in parallel.
Date: 2020-01-20 02:33:34
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

Allow vacuum command to process indexes in parallel.

This feature allows the vacuum to leverage multiple CPUs in order to
process indexes. This enables us to perform index vacuuming and index
cleanup with background workers. This adds a PARALLEL option to VACUUM
command where the user can specify the number of workers that can be used
to perform the command which is limited by the number of indexes on a
table. Specifying zero as a number of workers will disable parallelism.
This option can't be used with the FULL option.

Each index is processed by at most one vacuum process. Therefore parallel
vacuum can be used when the table has at least two indexes.

The parallel degree is either specified by the user or determined based on
the number of indexes that the table has, and further limited by
max_parallel_maintenance_workers. The index can participate in parallel
vacuum iff it's size is greater than min_parallel_index_scan_size.

Author: Masahiko Sawada and Amit Kapila
Reviewed-by: Dilip Kumar, Amit Kapila, Robert Haas, Tomas Vondra,
Mahendra Singh and Sergei Kornilov
Tested-by: Mahendra Singh and Prabhat Sahu



Modified Files
doc/src/sgml/config.sgml | 18 +-
doc/src/sgml/ref/vacuum.sgml | 61 +-
src/backend/access/heap/vacuumlazy.c | 1256 ++++++++++++++++++++++++++++++---
src/backend/access/transam/parallel.c | 26 +-
src/backend/commands/vacuum.c | 135 +++-
src/backend/postmaster/autovacuum.c | 2 +
src/bin/psql/tab-complete.c | 2 +-
src/include/access/heapam.h | 3 +
src/include/access/parallel.h | 4 +-
src/include/commands/vacuum.h | 12 +
src/test/regress/expected/vacuum.out | 34 +
src/test/regress/sql/vacuum.sql | 31 +
src/tools/pgindent/typedefs.list | 4 +
13 files changed, 1452 insertions(+), 136 deletions(-)


Browse pgsql-committers by date

  From Date Subject
Next Message Craig Ringer 2020-01-20 07:48:37 Re: pgsql: Allow 'sslkey' and 'sslcert' in postgres_fdw user mappings
Previous Message Tom Lane 2020-01-20 00:18:57 Re: pgsql: Add a non-strict version of jsonb_set