From 15729ba70e900450f60286721c00b5a209c8f7f1 Mon Sep 17 00:00:00 2001 From: houzj Date: Mon, 1 Feb 2021 11:24:43 +0800 Subject: [PATCH 2/2] reloption parallel_dml_enabled test and doc Test and document for reloption parallel_dml_enabled --- doc/src/sgml/ref/alter_table.sgml | 2 +- doc/src/sgml/ref/create_table.sgml | 22 ++++++++++++++++++++++ src/test/regress/expected/insert_parallel.out | 24 +++++++++++++++++++++--- src/test/regress/sql/insert_parallel.sql | 19 ++++++++++++++++--- 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index c25ef5a..ecb0470 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 569f4c9..4380184 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1408,6 +1408,28 @@ WITH ( MODULUS numeric_literal, REM + + parallel_dml_enabled (boolean) + + parallel_dml_enabled storage parameter + + + + + Enables or disables the parallel table-modification on a particular table. + if set it to true, planner will check parallel safety of the target table + to determine if it’s safe to execute parallel. (Note: If target is + partitioned table, it will check all its partitions and indexes, then + the check overhead can become prohibitively high if the number of + partitions is large, Especially when the parallelism is not chosen in + the end.) To avoid the overhead, the default is false. + Parallel_dml_enabled will not work if + is not set. If target table is parent table(partitioned), only the option + of the parent table works, the option values of its child will be 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 f98d1ae..641a5cc 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 5317313..4c6b352 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,18 +95,31 @@ 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.7.2.windows.1