From d3602c6fda71dcbb24f2df8edfebc9e2e98df52e Mon Sep 17 00:00:00 2001 From: houzj Date: Fri, 29 Jan 2021 13:58:29 +0800 Subject: [PATCH] reloption parallel_dml test and doc Test and document for reloption parallel_dml --- doc/src/sgml/ref/alter_table.sgml | 2 +- doc/src/sgml/ref/create_table.sgml | 22 +++++++ src/test/regress/expected/insert_parallel.out | 92 ++++++++++++++++----------- src/test/regress/sql/insert_parallel.sql | 87 ++++++++++++++----------- 4 files changed, 128 insertions(+), 75 deletions(-) diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index c25ef5a..e649f85 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. diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 569f4c9..c1f343e 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 (boolean) + + parallel_dml 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 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..6954c3c 100644 --- a/src/test/regress/expected/insert_parallel.out +++ b/src/test/regress/expected/insert_parallel.out @@ -21,12 +21,12 @@ create or replace function fullname_parallel_restricted(f text, l text) returns return f || l; end; $$ language plpgsql immutable parallel restricted; -create table names(index int, first_name text, last_name text); -create table names2(index int, first_name text, last_name text); +create table names(index int, first_name text, last_name text) with (parallel_dml = on); +create table names2(index int, first_name text, last_name text) with (parallel_dml = on); create index names2_fullname_idx on names2 (fullname_parallel_unsafe(first_name, last_name)); -create table names3(index int, first_name text, last_name text); +create table names3(index int, first_name text, last_name text) with (parallel_dml = on); create index names3_fullname_idx on names3 (fullname_parallel_safe(first_name, last_name)); -create table names4(index int, first_name text, last_name text); +create table names4(index int, first_name text, last_name text) with (parallel_dml = on); create index names4_fullname_idx on names4 (fullname_parallel_restricted(first_name, last_name)); insert into names values (1, 'albert', 'einstein'), @@ -53,8 +53,8 @@ returns int language plpgsql parallel safe as $$ begin RETURN 20; end $$; -create table testdef(a int, b int default bdefault_unsafe(), c int default cdefault_restricted(), d int default ddefault_safe()); -create table test_data(a int); +create table testdef(a int, b int default bdefault_unsafe(), c int default cdefault_restricted(), d int default ddefault_safe()) with (parallel_dml = on); +create table test_data(a int) with (parallel_dml = on); insert into test_data select * from generate_series(1,10); -- -- END: setup some tables and data needed by the tests. @@ -74,9 +74,9 @@ create table para_insert_p1 ( create table para_insert_f1 ( unique1 int4 REFERENCES para_insert_p1(unique1), stringu1 name -); +) with (parallel_dml = on); -- --- Test INSERT with underlying query when enable_parallel_dml=off. +-- Test INSERT with underlying query when enable_parallel_dml=off and reloption.parallel_dml=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=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 +-- +alter table para_insert_p1 set (parallel_dml = on); +-- -- Test INSERT with underlying query. -- (should create plan with parallel INSERT+SELECT, Gather parent node) -- @@ -305,9 +323,9 @@ reset max_parallel_workers; -- Test INSERT with ON CONFLICT ... DO UPDATE ... -- (should not create a parallel plan) -- -create table test_data2(like test_data); +create table test_data2(like test_data) with (parallel_dml = on); insert into test_data2 select i from generate_series(1,10000) i; -create table test_conflict_table(id serial primary key, somedata int); +create table test_conflict_table(id serial primary key, somedata int) with (parallel_dml = on); explain (costs off) insert into test_conflict_table(id, somedata) select a, a from test_data; QUERY PLAN -------------------------------------------- @@ -331,7 +349,7 @@ insert into test_conflict_table(id, somedata) select a, a from test_data ON CONF -- -- Test INSERT with parallelized aggregate -- -create table tenk1_avg_data(count int, avg_unique1 int, avg_stringu1_len int); +create table tenk1_avg_data(count int, avg_unique1 int, avg_stringu1_len int) with (parallel_dml = on); explain (costs off) insert into tenk1_avg_data select count(*), avg(unique1), avg(length(stringu1)) from tenk1; QUERY PLAN ---------------------------------------------------------- @@ -392,7 +410,7 @@ reset enable_indexscan; -- -- Test INSERT with parallel append -- -create table a_star_data(aa int); +create table a_star_data(aa int) with (parallel_dml = on); explain (costs off) insert into a_star_data select aa from a_star where aa > 10; QUERY PLAN -------------------------------------------------------- @@ -586,7 +604,7 @@ select * from names4 order by fullname_parallel_restricted(first_name, last_name -- Test INSERT with underlying query - and RETURNING (no projection) -- (should create a parallel plan; parallel INSERT+SELECT) -- -create table names5 (like names); +create table names5 (like names) with (parallel_dml = on); explain (costs off) insert into names5 select * from names returning *; QUERY PLAN ---------------------------------------- @@ -600,7 +618,7 @@ explain (costs off) insert into names5 select * from names returning *; -- Test INSERT with underlying ordered query - and RETURNING (no projection) -- (should create a parallel plan; INSERT + parallel SELECT) -- -create table names6 (like names); +create table names6 (like names) with (parallel_dml = on); explain (costs off) insert into names6 select * from names order by last_name returning *; QUERY PLAN ---------------------------------------------- @@ -629,7 +647,7 @@ insert into names6 select * from names order by last_name returning *; -- Test INSERT with underlying ordered query - and RETURNING (with projection) -- (should create a parallel plan; INSERT + parallel SELECT) -- -create table names7 (like names); +create table names7 (like names) with (parallel_dml = on); explain (costs off) insert into names7 select * from names order by last_name returning last_name || ', ' || first_name as last_name_then_first_name; QUERY PLAN ---------------------------------------------- @@ -658,7 +676,7 @@ insert into names7 select * from names order by last_name returning last_name || -- Test INSERT into temporary table with underlying query. -- (should not use a parallel plan) -- -create temporary table temp_names (like names); +create temporary table temp_names (like names) with (parallel_dml = on); explain (costs off) insert into temp_names select * from names; QUERY PLAN ---------------------------------------- @@ -822,9 +840,9 @@ truncate testdef; -- -- Test INSERT into partition with underlying query. -- -create table parttable1 (a int, b name) partition by range (a); -create table parttable1_1 partition of parttable1 for values from (0) to (5000); -create table parttable1_2 partition of parttable1 for values from (5000) to (10000); +create table parttable1 (a int, b name) partition by range (a) with (parallel_dml = on); +create table parttable1_1 partition of parttable1 for values from (0) to (5000) with (parallel_dml = on); +create table parttable1_2 partition of parttable1 for values from (5000) to (10000) with (parallel_dml = on); explain (costs off) insert into parttable1 select unique1,stringu1 from tenk1; QUERY PLAN ---------------------------------------- @@ -857,9 +875,9 @@ create operator class test_int4_ops for type int4 using btree as operator 1 < (int4,int4), operator 2 <= (int4,int4), operator 3 = (int4,int4), operator 4 >= (int4,int4), operator 5 > (int4,int4), function 1 my_int4_sort(int4,int4); -create table partkey_unsafe_key_supp_fn_t (a int4, b name) partition by range (a test_int4_ops); -create table partkey_unsafe_key_supp_fn_t_1 partition of partkey_unsafe_key_supp_fn_t for values from (0) to (5000); -create table partkey_unsafe_key_supp_fn_t_2 partition of partkey_unsafe_key_supp_fn_t for values from (5000) to (10000); +create table partkey_unsafe_key_supp_fn_t (a int4, b name) partition by range (a test_int4_ops) with (parallel_dml = on); +create table partkey_unsafe_key_supp_fn_t_1 partition of partkey_unsafe_key_supp_fn_t for values from (0) to (5000) with (parallel_dml = on); +create table partkey_unsafe_key_supp_fn_t_2 partition of partkey_unsafe_key_supp_fn_t for values from (5000) to (10000) with (parallel_dml = on); explain (costs off) insert into partkey_unsafe_key_supp_fn_t select unique1, stringu1 from tenk1; QUERY PLAN ---------------------------------------- @@ -871,7 +889,7 @@ explain (costs off) insert into partkey_unsafe_key_supp_fn_t select unique1, str -- Test INSERT into partition with parallel-unsafe partition key expression -- (should not create a parallel plan) -- -create table partkey_unsafe_key_expr_t (a int4, b name) partition by range ((fullname_parallel_unsafe('',a::varchar))); +create table partkey_unsafe_key_expr_t (a int4, b name) partition by range ((fullname_parallel_unsafe('',a::varchar))) with (parallel_dml = on); explain (costs off) insert into partkey_unsafe_key_expr_t select unique1, stringu1 from tenk1; QUERY PLAN ------------------------------------- @@ -888,7 +906,7 @@ create or replace function check_a(a int4) returns boolean as $$ return (a >= 0 and a <= 9999); end; $$ language plpgsql parallel safe; -create table table_check_a(a int4 check (check_a(a)), b name); +create table table_check_a(a int4 check (check_a(a)), b name) with (parallel_dml = on); explain (costs off) insert into table_check_a select unique1, stringu1 from tenk1; QUERY PLAN ---------------------------------------- @@ -914,7 +932,7 @@ create or replace function check_b_unsafe(b name) returns boolean as $$ return (b <> 'XXXXXX'); end; $$ language plpgsql parallel unsafe; -create table table_check_b(a int4, b name check (check_b_unsafe(b)), c name); +create table table_check_b(a int4, b name check (check_b_unsafe(b)), c name) with (parallel_dml = on); explain (costs off) insert into table_check_b(a,b,c) select unique1, unique2, stringu1 from tenk1; QUERY PLAN ------------------------- @@ -934,7 +952,7 @@ select count(*), sum(a) from table_check_b; -- (should create a parallel INSERT+SELECT plan; -- stmt-level before+after triggers should fire) -- -create table names_with_safe_trigger (like names); +create table names_with_safe_trigger (like names) with (parallel_dml = on); create or replace function insert_before_trigger_safe() returns trigger as $$ begin raise notice 'hello from insert_before_trigger_safe'; @@ -968,7 +986,7 @@ NOTICE: hello from insert_after_trigger_safe -- (should not create a parallel plan; -- stmt-level before+after triggers should fire) -- -create table names_with_unsafe_trigger (like names); +create table names_with_unsafe_trigger (like names) with (parallel_dml = on); create or replace function insert_before_trigger_unsafe() returns trigger as $$ begin raise notice 'hello from insert_before_trigger_unsafe'; @@ -1000,7 +1018,7 @@ NOTICE: hello from insert_after_trigger_unsafe -- (should create a parallel plan with INSERT + parallel SELECT; -- stmt-level before+after triggers should fire) -- -create table names_with_restricted_trigger (like names); +create table names_with_restricted_trigger (like names) with (parallel_dml = on); create or replace function insert_before_trigger_restricted() returns trigger as $$ begin raise notice 'hello from insert_before_trigger_restricted'; @@ -1033,9 +1051,9 @@ NOTICE: hello from insert_after_trigger_restricted -- Test INSERT into partition with parallel-unsafe trigger -- (should not create a parallel plan) -- -create table part_unsafe_trigger (a int4, b name) partition by range (a); -create table part_unsafe_trigger_1 partition of part_unsafe_trigger for values from (0) to (5000); -create table part_unsafe_trigger_2 partition of part_unsafe_trigger for values from (5000) to (10000); +create table part_unsafe_trigger (a int4, b name) partition by range (a) with (parallel_dml = on); +create table part_unsafe_trigger_1 partition of part_unsafe_trigger for values from (0) to (5000) with (parallel_dml = on); +create table part_unsafe_trigger_2 partition of part_unsafe_trigger for values from (5000) to (10000) with (parallel_dml = on); create trigger insert_before_trigger_unsafe before insert on part_unsafe_trigger_1 for each statement execute procedure insert_before_trigger_unsafe(); explain (costs off) insert into part_unsafe_trigger select unique1, stringu1 from tenk1; @@ -1048,8 +1066,8 @@ explain (costs off) insert into part_unsafe_trigger select unique1, stringu1 fro -- -- Test INSERT into table with TOAST column -- -create table insert_toast_table(index int4, data text); -create table insert_toast_table_data (like insert_toast_table); +create table insert_toast_table(index int4, data text) with (parallel_dml = on); +create table insert_toast_table_data (like insert_toast_table) with (parallel_dml = on); insert into insert_toast_table_data select i, rpad('T', 16384, 'ABCDEFGH') from generate_series(1,20) as i; explain (costs off) insert into insert_toast_table select index, data from insert_toast_table_data; QUERY PLAN @@ -1090,9 +1108,9 @@ create domain inotnull_r int check (sql_is_distinct_from_r(value, null)); create domain inotnull_s int check (sql_is_distinct_from_s(value, null)); -create table dom_table_u (x inotnull_u, y int); -create table dom_table_r (x inotnull_r, y int); -create table dom_table_s (x inotnull_s, y int); +create table dom_table_u (x inotnull_u, y int) with (parallel_dml = on); +create table dom_table_r (x inotnull_r, y int) with (parallel_dml = on); +create table dom_table_s (x inotnull_s, y int) with (parallel_dml = on); -- Test INSERT into table having a DOMAIN column with parallel-unsafe CHECK constraint explain (costs off) insert into dom_table_u select unique1, unique2 from tenk1; QUERY PLAN diff --git a/src/test/regress/sql/insert_parallel.sql b/src/test/regress/sql/insert_parallel.sql index 5317313..2f7b92a 100644 --- a/src/test/regress/sql/insert_parallel.sql +++ b/src/test/regress/sql/insert_parallel.sql @@ -27,12 +27,12 @@ create or replace function fullname_parallel_restricted(f text, l text) returns end; $$ language plpgsql immutable parallel restricted; -create table names(index int, first_name text, last_name text); -create table names2(index int, first_name text, last_name text); +create table names(index int, first_name text, last_name text) with (parallel_dml = on); +create table names2(index int, first_name text, last_name text) with (parallel_dml = on); create index names2_fullname_idx on names2 (fullname_parallel_unsafe(first_name, last_name)); -create table names3(index int, first_name text, last_name text); +create table names3(index int, first_name text, last_name text) with (parallel_dml = on); create index names3_fullname_idx on names3 (fullname_parallel_safe(first_name, last_name)); -create table names4(index int, first_name text, last_name text); +create table names4(index int, first_name text, last_name text) with (parallel_dml = on); create index names4_fullname_idx on names4 (fullname_parallel_restricted(first_name, last_name)); insert into names values @@ -65,9 +65,9 @@ begin RETURN 20; end $$; -create table testdef(a int, b int default bdefault_unsafe(), c int default cdefault_restricted(), d int default ddefault_safe()); +create table testdef(a int, b int default bdefault_unsafe(), c int default cdefault_restricted(), d int default ddefault_safe()) with (parallel_dml = on); -create table test_data(a int); +create table test_data(a int) with (parallel_dml = on); insert into test_data select * from generate_series(1,10); -- @@ -92,21 +92,34 @@ create table para_insert_p1 ( create table para_insert_f1 ( unique1 int4 REFERENCES para_insert_p1(unique1), stringu1 name -); +) with (parallel_dml = on); -- --- Test INSERT with underlying query when enable_parallel_dml=off. +-- Test INSERT with underlying query when enable_parallel_dml=off and reloption.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 +-- 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=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 +-- +alter table para_insert_p1 set (parallel_dml = on); + +-- -- Test INSERT with underlying query. -- (should create plan with parallel INSERT+SELECT, Gather parent node) -- @@ -171,9 +184,9 @@ reset max_parallel_workers; -- Test INSERT with ON CONFLICT ... DO UPDATE ... -- (should not create a parallel plan) -- -create table test_data2(like test_data); +create table test_data2(like test_data) with (parallel_dml = on); insert into test_data2 select i from generate_series(1,10000) i; -create table test_conflict_table(id serial primary key, somedata int); +create table test_conflict_table(id serial primary key, somedata int) with (parallel_dml = on); explain (costs off) insert into test_conflict_table(id, somedata) select a, a from test_data; insert into test_conflict_table(id, somedata) select a, a from test_data; explain (costs off) insert into test_conflict_table(id, somedata) select a, a from test_data ON CONFLICT(id) DO UPDATE SET somedata = EXCLUDED.somedata + 1; @@ -182,7 +195,7 @@ insert into test_conflict_table(id, somedata) select a, a from test_data ON CONF -- -- Test INSERT with parallelized aggregate -- -create table tenk1_avg_data(count int, avg_unique1 int, avg_stringu1_len int); +create table tenk1_avg_data(count int, avg_unique1 int, avg_stringu1_len int) with (parallel_dml = on); explain (costs off) insert into tenk1_avg_data select count(*), avg(unique1), avg(length(stringu1)) from tenk1; insert into tenk1_avg_data select count(*), avg(unique1), avg(length(stringu1)) from tenk1; select * from tenk1_avg_data; @@ -203,7 +216,7 @@ reset enable_indexscan; -- -- Test INSERT with parallel append -- -create table a_star_data(aa int); +create table a_star_data(aa int) with (parallel_dml = on); explain (costs off) insert into a_star_data select aa from a_star where aa > 10; insert into a_star_data select aa from a_star where aa > 10; select count(aa), sum(aa) from a_star_data; @@ -264,14 +277,14 @@ select * from names4 order by fullname_parallel_restricted(first_name, last_name -- Test INSERT with underlying query - and RETURNING (no projection) -- (should create a parallel plan; parallel INSERT+SELECT) -- -create table names5 (like names); +create table names5 (like names) with (parallel_dml = on); explain (costs off) insert into names5 select * from names returning *; -- -- Test INSERT with underlying ordered query - and RETURNING (no projection) -- (should create a parallel plan; INSERT + parallel SELECT) -- -create table names6 (like names); +create table names6 (like names) with (parallel_dml = on); explain (costs off) insert into names6 select * from names order by last_name returning *; insert into names6 select * from names order by last_name returning *; @@ -279,7 +292,7 @@ insert into names6 select * from names order by last_name returning *; -- Test INSERT with underlying ordered query - and RETURNING (with projection) -- (should create a parallel plan; INSERT + parallel SELECT) -- -create table names7 (like names); +create table names7 (like names) with (parallel_dml = on); explain (costs off) insert into names7 select * from names order by last_name returning last_name || ', ' || first_name as last_name_then_first_name; insert into names7 select * from names order by last_name returning last_name || ', ' || first_name as last_name_then_first_name; @@ -287,7 +300,7 @@ insert into names7 select * from names order by last_name returning last_name || -- Test INSERT into temporary table with underlying query. -- (should not use a parallel plan) -- -create temporary table temp_names (like names); +create temporary table temp_names (like names) with (parallel_dml = on); explain (costs off) insert into temp_names select * from names; insert into temp_names select * from names; @@ -344,9 +357,9 @@ truncate testdef; -- -- Test INSERT into partition with underlying query. -- -create table parttable1 (a int, b name) partition by range (a); -create table parttable1_1 partition of parttable1 for values from (0) to (5000); -create table parttable1_2 partition of parttable1 for values from (5000) to (10000); +create table parttable1 (a int, b name) partition by range (a) with (parallel_dml = on); +create table parttable1_1 partition of parttable1 for values from (0) to (5000) with (parallel_dml = on); +create table parttable1_2 partition of parttable1 for values from (5000) to (10000) with (parallel_dml = on); explain (costs off) insert into parttable1 select unique1,stringu1 from tenk1; insert into parttable1 select unique1,stringu1 from tenk1; @@ -365,9 +378,9 @@ create operator class test_int4_ops for type int4 using btree as operator 3 = (int4,int4), operator 4 >= (int4,int4), operator 5 > (int4,int4), function 1 my_int4_sort(int4,int4); -create table partkey_unsafe_key_supp_fn_t (a int4, b name) partition by range (a test_int4_ops); -create table partkey_unsafe_key_supp_fn_t_1 partition of partkey_unsafe_key_supp_fn_t for values from (0) to (5000); -create table partkey_unsafe_key_supp_fn_t_2 partition of partkey_unsafe_key_supp_fn_t for values from (5000) to (10000); +create table partkey_unsafe_key_supp_fn_t (a int4, b name) partition by range (a test_int4_ops) with (parallel_dml = on); +create table partkey_unsafe_key_supp_fn_t_1 partition of partkey_unsafe_key_supp_fn_t for values from (0) to (5000) with (parallel_dml = on); +create table partkey_unsafe_key_supp_fn_t_2 partition of partkey_unsafe_key_supp_fn_t for values from (5000) to (10000) with (parallel_dml = on); explain (costs off) insert into partkey_unsafe_key_supp_fn_t select unique1, stringu1 from tenk1; @@ -375,7 +388,7 @@ explain (costs off) insert into partkey_unsafe_key_supp_fn_t select unique1, str -- Test INSERT into partition with parallel-unsafe partition key expression -- (should not create a parallel plan) -- -create table partkey_unsafe_key_expr_t (a int4, b name) partition by range ((fullname_parallel_unsafe('',a::varchar))); +create table partkey_unsafe_key_expr_t (a int4, b name) partition by range ((fullname_parallel_unsafe('',a::varchar))) with (parallel_dml = on); explain (costs off) insert into partkey_unsafe_key_expr_t select unique1, stringu1 from tenk1; -- @@ -388,7 +401,7 @@ create or replace function check_a(a int4) returns boolean as $$ end; $$ language plpgsql parallel safe; -create table table_check_a(a int4 check (check_a(a)), b name); +create table table_check_a(a int4 check (check_a(a)), b name) with (parallel_dml = on); explain (costs off) insert into table_check_a select unique1, stringu1 from tenk1; insert into table_check_a select unique1, stringu1 from tenk1; select count(*), sum(a) from table_check_a; @@ -403,7 +416,7 @@ create or replace function check_b_unsafe(b name) returns boolean as $$ end; $$ language plpgsql parallel unsafe; -create table table_check_b(a int4, b name check (check_b_unsafe(b)), c name); +create table table_check_b(a int4, b name check (check_b_unsafe(b)), c name) with (parallel_dml = on); explain (costs off) insert into table_check_b(a,b,c) select unique1, unique2, stringu1 from tenk1; insert into table_check_b(a,b,c) select unique1, stringu1, stringu2 from tenk1; select count(*), sum(a) from table_check_b; @@ -413,7 +426,7 @@ select count(*), sum(a) from table_check_b; -- (should create a parallel INSERT+SELECT plan; -- stmt-level before+after triggers should fire) -- -create table names_with_safe_trigger (like names); +create table names_with_safe_trigger (like names) with (parallel_dml = on); create or replace function insert_before_trigger_safe() returns trigger as $$ begin raise notice 'hello from insert_before_trigger_safe'; @@ -438,7 +451,7 @@ insert into names_with_safe_trigger select * from names; -- (should not create a parallel plan; -- stmt-level before+after triggers should fire) -- -create table names_with_unsafe_trigger (like names); +create table names_with_unsafe_trigger (like names) with (parallel_dml = on); create or replace function insert_before_trigger_unsafe() returns trigger as $$ begin raise notice 'hello from insert_before_trigger_unsafe'; @@ -463,7 +476,7 @@ insert into names_with_unsafe_trigger select * from names; -- (should create a parallel plan with INSERT + parallel SELECT; -- stmt-level before+after triggers should fire) -- -create table names_with_restricted_trigger (like names); +create table names_with_restricted_trigger (like names) with (parallel_dml = on); create or replace function insert_before_trigger_restricted() returns trigger as $$ begin raise notice 'hello from insert_before_trigger_restricted'; @@ -488,9 +501,9 @@ insert into names_with_restricted_trigger select * from names; -- (should not create a parallel plan) -- -create table part_unsafe_trigger (a int4, b name) partition by range (a); -create table part_unsafe_trigger_1 partition of part_unsafe_trigger for values from (0) to (5000); -create table part_unsafe_trigger_2 partition of part_unsafe_trigger for values from (5000) to (10000); +create table part_unsafe_trigger (a int4, b name) partition by range (a) with (parallel_dml = on); +create table part_unsafe_trigger_1 partition of part_unsafe_trigger for values from (0) to (5000) with (parallel_dml = on); +create table part_unsafe_trigger_2 partition of part_unsafe_trigger for values from (5000) to (10000) with (parallel_dml = on); create trigger insert_before_trigger_unsafe before insert on part_unsafe_trigger_1 for each statement execute procedure insert_before_trigger_unsafe(); @@ -499,8 +512,8 @@ explain (costs off) insert into part_unsafe_trigger select unique1, stringu1 fro -- -- Test INSERT into table with TOAST column -- -create table insert_toast_table(index int4, data text); -create table insert_toast_table_data (like insert_toast_table); +create table insert_toast_table(index int4, data text) with (parallel_dml = on); +create table insert_toast_table_data (like insert_toast_table) with (parallel_dml = on); insert into insert_toast_table_data select i, rpad('T', 16384, 'ABCDEFGH') from generate_series(1,20) as i; explain (costs off) insert into insert_toast_table select index, data from insert_toast_table_data; insert into insert_toast_table select index, data from insert_toast_table_data; @@ -535,9 +548,9 @@ create domain inotnull_r int create domain inotnull_s int check (sql_is_distinct_from_s(value, null)); -create table dom_table_u (x inotnull_u, y int); -create table dom_table_r (x inotnull_r, y int); -create table dom_table_s (x inotnull_s, y int); +create table dom_table_u (x inotnull_u, y int) with (parallel_dml = on); +create table dom_table_r (x inotnull_r, y int) with (parallel_dml = on); +create table dom_table_s (x inotnull_s, y int) with (parallel_dml = on); -- Test INSERT into table having a DOMAIN column with parallel-unsafe CHECK constraint -- 2.7.2.windows.1