From bb03a81da4e728c383d4cde8548198f38dcef01b Mon Sep 17 00:00:00 2001 From: Tomas Vondra Date: Sun, 22 Jan 2017 17:47:59 +0100 Subject: [PATCH] accept valid plan changes to parallel queries in select_parallel This typically means additional Remote Subquery Scan somewhere in the plan. --- src/test/regress/expected/select_parallel.out | 118 ++++++++++-------- 1 file changed, 63 insertions(+), 55 deletions(-) diff --git a/src/test/regress/expected/select_parallel.out b/src/test/regress/expected/select_parallel.out index 2286fafab3..78d32e08ff 100644 --- a/src/test/regress/expected/select_parallel.out +++ b/src/test/regress/expected/select_parallel.out @@ -13,20 +13,21 @@ set min_parallel_relation_size=0; set max_parallel_workers_per_gather=4; explain (costs off) select count(*) from a_star; - QUERY PLAN ------------------------------------------------------ + QUERY PLAN +----------------------------------------------------------- Finalize Aggregate - -> Gather - Workers Planned: 1 - -> Partial Aggregate - -> Append - -> Parallel Seq Scan on a_star - -> Parallel Seq Scan on b_star - -> Parallel Seq Scan on c_star - -> Parallel Seq Scan on d_star - -> Parallel Seq Scan on e_star - -> Parallel Seq Scan on f_star -(11 rows) + -> Remote Subquery Scan on all (datanode_1,datanode_2) + -> Gather + Workers Planned: 1 + -> Partial Aggregate + -> Append + -> Parallel Seq Scan on a_star + -> Parallel Seq Scan on b_star + -> Parallel Seq Scan on c_star + -> Parallel Seq Scan on d_star + -> Parallel Seq Scan on e_star + -> Parallel Seq Scan on f_star +(12 rows) select count(*) from a_star; count @@ -39,32 +40,35 @@ alter table tenk1 set (parallel_workers = 4); explain (verbose, costs off) select parallel_restricted(unique1) from tenk1 where stringu1 = 'GRAAAA' order by 1; - QUERY PLAN ---------------------------------------------------------- - Sort - Output: (parallel_restricted(unique1)) - Sort Key: (parallel_restricted(tenk1.unique1)) - -> Gather - Output: parallel_restricted(unique1) - Workers Planned: 4 - -> Parallel Seq Scan on public.tenk1 - Output: unique1 - Filter: (tenk1.stringu1 = 'GRAAAA'::name) -(9 rows) + QUERY PLAN +--------------------------------------------------------------- + Remote Subquery Scan on all (datanode_1,datanode_2) + Output: parallel_restricted(unique1) + -> Sort + Output: (parallel_restricted(unique1)) + Sort Key: (parallel_restricted(tenk1.unique1)) + -> Gather + Output: parallel_restricted(unique1) + Workers Planned: 4 + -> Parallel Seq Scan on public.tenk1 + Output: unique1 + Filter: (tenk1.stringu1 = 'GRAAAA'::name) +(11 rows) -- test parallel plan when group by expression is in target list. explain (costs off) select length(stringu1) from tenk1 group by length(stringu1); - QUERY PLAN ---------------------------------------------------- + QUERY PLAN +----------------------------------------------------------- Finalize HashAggregate - Group Key: (length((stringu1)::text)) - -> Gather - Workers Planned: 4 - -> Partial HashAggregate - Group Key: length((stringu1)::text) - -> Parallel Seq Scan on tenk1 -(7 rows) + Group Key: length((stringu1)::text) + -> Remote Subquery Scan on all (datanode_1,datanode_2) + -> Gather + Workers Planned: 4 + -> Partial HashAggregate + Group Key: length((stringu1)::text) + -> Parallel Seq Scan on tenk1 +(8 rows) select length(stringu1) from tenk1 group by length(stringu1); length @@ -74,42 +78,46 @@ select length(stringu1) from tenk1 group by length(stringu1); explain (costs off) select stringu1, count(*) from tenk1 group by stringu1 order by stringu1; - QUERY PLAN ----------------------------------------------------- + QUERY PLAN +----------------------------------------------------------------- Sort Sort Key: stringu1 - -> Finalize HashAggregate + -> Finalize GroupAggregate Group Key: stringu1 - -> Gather - Workers Planned: 4 + -> Remote Subquery Scan on all (datanode_1,datanode_2) -> Partial HashAggregate Group Key: stringu1 - -> Parallel Seq Scan on tenk1 -(9 rows) + -> Gather + Workers Planned: 4 + -> Parallel Seq Scan on tenk1 +(10 rows) -- test that parallel plan for aggregates is not selected when -- target list contains parallel restricted clause. explain (costs off) select sum(parallel_restricted(unique1)) from tenk1 group by(parallel_restricted(unique1)); - QUERY PLAN ----------------------------------------------------- + QUERY PLAN +----------------------------------------------------------- HashAggregate Group Key: parallel_restricted(unique1) - -> Index Only Scan using tenk1_unique1 on tenk1 -(3 rows) + -> Remote Subquery Scan on all (datanode_1,datanode_2) + -> Index Only Scan using tenk1_unique1 on tenk1 +(4 rows) set force_parallel_mode=1; explain (costs off) select stringu1::int2 from tenk1 where unique1 = 1; - QUERY PLAN ------------------------------------------------ - Gather - Workers Planned: 1 - Single Copy: true - -> Index Scan using tenk1_unique1 on tenk1 - Index Cond: (unique1 = 1) -(5 rows) + QUERY PLAN +----------------------------------------------------- + Remote Fast Query Execution + Node/s: datanode_1 + -> Gather + Workers Planned: 1 + Single Copy: true + -> Index Scan using tenk1_unique1 on tenk1 + Index Cond: (unique1 = 1) +(7 rows) do $$begin -- Provoke error, possibly in worker. If this error happens to occur in @@ -119,6 +127,6 @@ do $$begin when others then raise 'SQLERRM: %', sqlerrm; end$$; -ERROR: SQLERRM: invalid input syntax for integer: "BAAAAA" -CONTEXT: PL/pgSQL function inline_code_block line 7 at RAISE +ERROR: Internal subtransactions not supported in Postgres-XL +CONTEXT: PL/pgSQL function inline_code_block line 1 during statement block entry rollback; -- 2.39.5