From c8f78b616167bf8e24bc5dc69112c37755ed3058 Mon Sep 17 00:00:00 2001 From: Amit Kapila Date: Thu, 18 Mar 2021 07:25:27 +0530 Subject: Add a new GUC and a reloption to enable inserts in parallel-mode. Commit 05c8482f7f added the implementation of parallel SELECT for "INSERT INTO ... SELECT ..." which may incur non-negligible overhead in the additional parallel-safety checks that it performs, even when, in the end, those checks determine that parallelism can't be used. This is normally only ever a problem in the case of when the target table has a large number of partitions. A new GUC option "enable_parallel_insert" is added, to allow insert in parallel-mode. The default is on. In addition to the GUC option, the user may want a mechanism to allow inserts in parallel-mode with finer granularity at table level. The new table option "parallel_insert_enabled" allows this. The default is true. Author: "Hou, Zhijie" Reviewed-by: Greg Nancarrow, Amit Langote, Takayuki Tsunakawa, Amit Kapila Discussion: https://postgr.es/m/CAA4eK1K-cW7svLC2D7DHoGHxdAdg3P37BLgebqBOC2ZLc9a6QQ%40mail.gmail.com Discussion: https://postgr.es/m/CAJcOf-cXnB5cnMKqWEp2E2z7Mvcd04iLVmV=qpFJrR3AcrTS3g@mail.gmail.com --- doc/src/sgml/config.sgml | 23 +++++++++++++++++++++++ doc/src/sgml/ref/alter_table.sgml | 3 ++- doc/src/sgml/ref/create_table.sgml | 26 ++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) (limited to 'doc/src') diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 5e551b9f6d6..8603cf3f941 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -5072,6 +5072,29 @@ ANY num_sync ( + enable_parallel_insert (boolean) + + enable_parallel_insert configuration parameter + + + + + Enables or disables the query planner's use of parallel plans for + INSERT commands. The default is on. + When enabled, the planner performs additional parallel-safety checks + on the target table's attributes and indexes, in order to determine + if it's safe to use a parallel plan for INSERT. In + cases such as when the target table has a large number of partitions, + and particularly also when that table uses something parallel-unsafe + that prevents parallelism, the overhead of these checks may become + prohibitively high. To address this potential overhead in these cases, + this option can be used to disable the use of parallel plans for + INSERT. + + + + diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index c25ef5abd6a..f82dce4a597 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -722,7 +722,8 @@ WITH ( MODULUS numeric_literal, REM SHARE UPDATE EXCLUSIVE lock will be taken for fillfactor, toast and autovacuum storage parameters, as well as the - planner parameter parallel_workers. + planner parameter parallel_workers and + parallel_insert_enabled. diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 71703da85ae..ff1b642722a 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1409,6 +1409,32 @@ WITH ( MODULUS numeric_literal, REM + + parallel_insert_enabled (boolean) + + parallel_insert_enabled storage parameter + + + + + Enables or disables the query planner's use of parallel insert for + this table. When enabled (and provided that + is also true), + the planner performs additional parallel-safety checks on the table's + attributes and indexes, in order to determine if it's safe to use a + parallel plan for INSERT. The default is + true. In cases such as when the table has a large + number of partitions, and particularly also when that table uses a + parallel-unsafe feature that prevents parallelism, the overhead of these + checks may become prohibitively high. To address this potential overhead + in these cases, this option can be used to disable the use of parallel + insert for this table. Note that if the target table of the parallel + insert is partitioned, the parallel_insert_enabled + option values of the partitions are ignored. + + + + autovacuum_enabled, toast.autovacuum_enabled (boolean) -- cgit v1.2.3