From b34e392905c0ec4b1835f05d2af8b297390ce325 Mon Sep 17 00:00:00 2001 From: Greg Nancarrow Date: Tue, 2 Feb 2021 10:03:45 +1100 Subject: [PATCH v3 2/2] reloption parallel_dml_enabled test and doc Test and documentation updates for reloption parallel_dml_enabled. --- doc/src/sgml/ref/alter_table.sgml | 2 +- doc/src/sgml/ref/create_table.sgml | 27 +++++++++++++++++++ src/test/regress/expected/insert_parallel.out | 24 ++++++++++++++--- src/test/regress/sql/insert_parallel.sql | 19 ++++++++++--- 4 files changed, 65 insertions(+), 7 deletions(-) diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index c25ef5abd6..ecb047021d 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -722,7 +722,7 @@ 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_dml_enabled. diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 569f4c9da7..420cbcfd7c 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1408,6 +1408,33 @@ WITH ( MODULUS numeric_literal, REM + + parallel_dml_enabled (boolean) + + parallel_dml_enabled storage parameter + + + + + Enables or disables the query planner's use of parallel DML 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 table-modification. 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 DML for this table. + Note that if the target table of the parallel DML is partitioned, the + parallel_dml_enabled option values of the partitions are + ignored. + + + + autovacuum_enabled, toast.autovacuum_enabled (boolean) diff --git a/src/test/regress/expected/insert_parallel.out b/src/test/regress/expected/insert_parallel.out index f98d1aec7f..641a5cc0ca 100644 --- a/src/test/regress/expected/insert_parallel.out +++ b/src/test/regress/expected/insert_parallel.out @@ -70,13 +70,13 @@ set max_parallel_workers_per_gather=4; create table para_insert_p1 ( unique1 int4 PRIMARY KEY, stringu1 name -); +) with (parallel_dml_enabled = off); create table para_insert_f1 ( unique1 int4 REFERENCES para_insert_p1(unique1), stringu1 name ); -- --- Test INSERT with underlying query when enable_parallel_dml=off. +-- Test INSERT with underlying query when enable_parallel_dml=off and reloption.parallel_dml_enabled=off. -- (should create plan with serial INSERT + SELECT) -- explain(costs off) insert into para_insert_p1 select unique1, stringu1 from tenk1; @@ -88,10 +88,28 @@ explain(costs off) insert into para_insert_p1 select unique1, stringu1 from tenk insert into para_insert_p1 select unique1, stringu1 from tenk1; -- --- Enable parallel dml +-- Enable guc option enable_parallel_dml -- set enable_parallel_dml = on; -- +-- Test INSERT with underlying query when enable_parallel_dml=on and reloption.parallel_dml_enabled=off. +-- (should create plan with serial INSERT + SELECT) +-- +truncate para_insert_p1 cascade; +NOTICE: truncate cascades to table "para_insert_f1" +explain(costs off) insert into para_insert_p1 select unique1, stringu1 from tenk1; + QUERY PLAN +-------------------------- + Insert on para_insert_p1 + -> Seq Scan on tenk1 +(2 rows) + +insert into para_insert_p1 select unique1, stringu1 from tenk1; +-- +-- Enable reloption parallel_dml_enabled +-- +alter table para_insert_p1 set (parallel_dml_enabled = on); +-- -- Test INSERT with underlying query. -- (should create plan with parallel INSERT+SELECT, Gather parent node) -- diff --git a/src/test/regress/sql/insert_parallel.sql b/src/test/regress/sql/insert_parallel.sql index 531731378e..4c6b352986 100644 --- a/src/test/regress/sql/insert_parallel.sql +++ b/src/test/regress/sql/insert_parallel.sql @@ -87,7 +87,7 @@ set max_parallel_workers_per_gather=4; create table para_insert_p1 ( unique1 int4 PRIMARY KEY, stringu1 name -); +) with (parallel_dml_enabled = off); create table para_insert_f1 ( unique1 int4 REFERENCES para_insert_p1(unique1), @@ -95,17 +95,30 @@ create table para_insert_f1 ( ); -- --- Test INSERT with underlying query when enable_parallel_dml=off. +-- Test INSERT with underlying query when enable_parallel_dml=off and reloption.parallel_dml_enabled=off. -- (should create plan with serial INSERT + SELECT) -- explain(costs off) insert into para_insert_p1 select unique1, stringu1 from tenk1; insert into para_insert_p1 select unique1, stringu1 from tenk1; -- --- Enable parallel dml +-- Enable guc option enable_parallel_dml -- set enable_parallel_dml = on; +-- +-- Test INSERT with underlying query when enable_parallel_dml=on and reloption.parallel_dml_enabled=off. +-- (should create plan with serial INSERT + SELECT) +-- +truncate para_insert_p1 cascade; +explain(costs off) insert into para_insert_p1 select unique1, stringu1 from tenk1; +insert into para_insert_p1 select unique1, stringu1 from tenk1; + +-- +-- Enable reloption parallel_dml_enabled +-- +alter table para_insert_p1 set (parallel_dml_enabled = on); + -- -- Test INSERT with underlying query. -- (should create plan with parallel INSERT+SELECT, Gather parent node) -- 2.27.0