summaryrefslogtreecommitdiff
path: root/src/include/commands
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2020-01-20 07:57:49 +0530
committerAmit Kapila <akapila@postgresql.org>2020-01-20 07:57:49 +0530
commit40d964ec997f64227bc0ff5e058dc4a5770a70a9 (patch)
treeb1cd42a23dde30447f755edc5ee8cd0fe8d74c31 /src/include/commands
parent44f1fc8df5dadbc5e80661660903aab4076d868f (diff)
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 Discussion: https://postgr.es/m/CAD21AoDTPMgzSkV4E3SFo1CH_x50bf5PqZFQf4jmqjk-C03BWg@mail.gmail.com https://postgr.es/m/CAA4eK1J-VoR9gzS5E75pcD-OH0mEyCdp8RihcwKrcuw7J-Q0+w@mail.gmail.com
Diffstat (limited to 'src/include/commands')
-rw-r--r--src/include/commands/vacuum.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index b3351ad4062..c27d255d8da 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -222,6 +222,13 @@ typedef struct VacuumParams
* default value depends on reloptions */
VacOptTernaryValue truncate; /* Truncate empty pages at the end,
* default value depends on reloptions */
+
+ /*
+ * The number of parallel vacuum workers. 0 by default which means choose
+ * based on the number of indexes. -1 indicates a parallel vacuum is
+ * disabled.
+ */
+ int nworkers;
} VacuumParams;
/* GUC parameters */
@@ -231,6 +238,11 @@ extern int vacuum_freeze_table_age;
extern int vacuum_multixact_freeze_min_age;
extern int vacuum_multixact_freeze_table_age;
+/* Variables for cost-based parallel vacuum */
+extern pg_atomic_uint32 *VacuumSharedCostBalance;
+extern pg_atomic_uint32 *VacuumActiveNWorkers;
+extern int VacuumCostBalanceLocal;
+
/* in commands/vacuum.c */
extern void ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel);