From eb4ea2423d3ab63fd87767afcfe7560c7e2e39ad Mon Sep 17 00:00:00 2001 From: houzj Date: Fri, 29 Jan 2021 10:30:18 +0800 Subject: [PATCH 2/2] guc option enable_parallel_dml doc and test Test and document for enable_parallel_dml --- doc/src/sgml/config.sgml | 19 +++++++++++++++++++ src/test/regress/expected/insert_parallel.out | 18 ++++++++++++++++++ src/test/regress/expected/sysviews.out | 3 ++- src/test/regress/sql/insert_parallel.sql | 12 ++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 82864bb..c895999 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -5024,6 +5024,25 @@ ANY num_sync ( + enable_parallel_dml (boolean) + + enable_parallel_dml configuration parameter + + + + + Enables or disables the parallel mode for table-modification command. + if set it to on, 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 off. + + + + diff --git a/src/test/regress/expected/insert_parallel.out b/src/test/regress/expected/insert_parallel.out index 3b922a2..f98d1ae 100644 --- a/src/test/regress/expected/insert_parallel.out +++ b/src/test/regress/expected/insert_parallel.out @@ -76,9 +76,27 @@ create table para_insert_f1 ( stringu1 name ); -- +-- Test INSERT with underlying query when enable_parallel_dml=off. +-- (should create plan with serial INSERT + SELECT) +-- +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 parallel dml +-- +set enable_parallel_dml = on; +-- -- Test INSERT with underlying query. -- (should create plan with parallel INSERT+SELECT, Gather parent node) -- +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 ---------------------------------------- diff --git a/src/test/regress/expected/sysviews.out b/src/test/regress/expected/sysviews.out index 81bdacf..3f11216 100644 --- a/src/test/regress/expected/sysviews.out +++ b/src/test/regress/expected/sysviews.out @@ -99,6 +99,7 @@ select name, setting from pg_settings where name like 'enable%'; enable_mergejoin | on enable_nestloop | on enable_parallel_append | on + enable_parallel_dml | off enable_parallel_hash | on enable_partition_pruning | on enable_partitionwise_aggregate | off @@ -106,7 +107,7 @@ select name, setting from pg_settings where name like 'enable%'; enable_seqscan | on enable_sort | on enable_tidscan | on -(18 rows) +(19 rows) -- Test that the pg_timezone_names and pg_timezone_abbrevs views are -- more-or-less working. We can't test their contents in any great detail diff --git a/src/test/regress/sql/insert_parallel.sql b/src/test/regress/sql/insert_parallel.sql index 34a191f..5317313 100644 --- a/src/test/regress/sql/insert_parallel.sql +++ b/src/test/regress/sql/insert_parallel.sql @@ -94,11 +94,23 @@ create table para_insert_f1 ( stringu1 name ); +-- +-- Test INSERT with underlying query when enable_parallel_dml=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 +-- +set enable_parallel_dml = on; -- -- Test INSERT with underlying query. -- (should create plan with parallel INSERT+SELECT, Gather parent node) -- +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; -- select some values to verify that the parallel insert worked -- 2.7.2.windows.1