Remove have_gather_plan_node.
This commit is contained in:
@ -68,7 +68,6 @@ static void set_plain_rel_size(PlannerInfo* root, RelOptInfo* rel, RangeTblEntry
|
||||
static void create_plain_partial_paths(PlannerInfo* root, RelOptInfo* rel);
|
||||
static void set_tablesample_rel_size(PlannerInfo* root, RelOptInfo* rel, RangeTblEntry* rte);
|
||||
static void set_plain_rel_pathlist(PlannerInfo* root, RelOptInfo* rel, RangeTblEntry* rte);
|
||||
static void have_gather_plan_node(Plan* plan, void* context, const char* query_string);
|
||||
static void set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte);
|
||||
static void set_foreign_size(PlannerInfo* root, RelOptInfo* rel, RangeTblEntry* rte);
|
||||
static void set_foreign_pathlist(PlannerInfo* root, RelOptInfo* rel, RangeTblEntry* rte);
|
||||
@ -281,16 +280,6 @@ static void set_base_rel_sizes(PlannerInfo* root)
|
||||
set_rel_consider_parallel(root, rel, root->simple_rte_array[rti]);
|
||||
|
||||
set_rel_size(root, rel, (Index)rti, root->simple_rte_array[rti]);
|
||||
|
||||
/* we have not merge the commit that change plan generation,
|
||||
* so we temporarily use this function to avoid gather-nesting problem. */
|
||||
if (root->simple_rte_array[rti]->rtekind == RTE_SUBQUERY && rel->subplan != NULL) {
|
||||
bool have_gather = false;
|
||||
have_gather_plan_node(rel->subplan, (void*)&have_gather, NULL);
|
||||
if (have_gather)
|
||||
rel->consider_parallel = false;
|
||||
}
|
||||
|
||||
/* Try inlist2join optimization */
|
||||
inlist2join_qrw_optimization(root, rti);
|
||||
}
|
||||
@ -1002,20 +991,6 @@ static void set_plain_rel_pathlist(PlannerInfo* root, RelOptInfo* rel, RangeTblE
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* we have not merge the commit that change plan generation,
|
||||
* so we temporarily use this function to avoid gather-nesting problem.
|
||||
*/
|
||||
static void have_gather_plan_node(Plan* plan, void* context, const char* query_string)
|
||||
{
|
||||
if (IsA(plan, Gather)) {
|
||||
bool* result = (bool*)context;
|
||||
*result = true;
|
||||
} else {
|
||||
PlanTreeWalker(plan, have_gather_plan_node, context, query_string);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If this relation could possibly be scanned from within a worker, then set
|
||||
* its consider_parallel flag.
|
||||
@ -1036,9 +1011,10 @@ static void set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel, RangeT
|
||||
|
||||
/* Assorted checks based on rtekind. */
|
||||
switch (rte->rtekind) {
|
||||
case RTE_RELATION:
|
||||
case RTE_RELATION: {
|
||||
/*
|
||||
* Currently, parallel workers can't access the leader's temporary
|
||||
* Don't support parallel query in next cases:
|
||||
* 1. Currently, parallel workers can't access the leader's temporary
|
||||
* tables. We could possibly relax this if the wrote all of its
|
||||
* local buffers at the start of the query and made no changes
|
||||
* thereafter (maybe we could allow hint bit changes), and if we
|
||||
@ -1046,14 +1022,14 @@ static void set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel, RangeT
|
||||
* temporary buffers could be expensive, though, and we don't have
|
||||
* the rest of the necessary infrastructure right now anyway. So
|
||||
* for now, bail out if we see a temporary table.
|
||||
*
|
||||
* Don't support parallel query for foreign table.
|
||||
* 2. Global temp table.
|
||||
* 3. Foreign table.
|
||||
* 4. partitioned table.
|
||||
* 5. non row-oriented table.
|
||||
*/
|
||||
if (get_rel_persistence(rte->relid) == RELPERSISTENCE_TEMP || rte->relkind == RELKIND_FOREIGN_TABLE) {
|
||||
return;
|
||||
}
|
||||
/* Don't support parallel for partitioned table. */
|
||||
if (rte->ispartrel) {
|
||||
char persistence = get_rel_persistence(rte->relid);
|
||||
if (persistence == RELPERSISTENCE_TEMP || persistence == RELPERSISTENCE_GLOBAL_TEMP ||
|
||||
rte->relkind == RELKIND_FOREIGN_TABLE || rte->ispartrel || rel->orientation != REL_ROW_ORIENTED) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1072,7 +1048,7 @@ static void set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel, RangeT
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
case RTE_SUBQUERY:
|
||||
/*
|
||||
* Subplans currently aren't passed to workers. Even if they
|
||||
@ -1082,14 +1058,6 @@ static void set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel, RangeT
|
||||
* involves any parallel-restricted operations. It would be
|
||||
* nice to relax this restriction some day, but it's going to
|
||||
* take a fair amount of work.
|
||||
*
|
||||
* we have not merge the commit that change plan generation,
|
||||
* so the problem mentioned above have not been solved very well.
|
||||
* but if rte->kind is RTE_SUBQUERY, it means rel will have subplan
|
||||
* so we temporarily use function have_gather_plan_node to find out
|
||||
* if there is a Gather plan node in rel->subplan, if yes, do not
|
||||
* consider parallel about this rel to avoid gather-nesting problem.
|
||||
* see have_gather_plan_node, and it is not a good idea.
|
||||
*/
|
||||
break;
|
||||
|
||||
|
||||
@ -2029,7 +2029,7 @@ static void ExecutePlan(EState *estate, PlanState *planstate, bool use_parallel_
|
||||
slot = NULL;
|
||||
}
|
||||
/******************************* MOT LLVM *************************************/
|
||||
else if (!IS_PGXC_COORDINATOR && JitExec::IsMotCodegenEnabled() && mot_jit_context) {
|
||||
else if (mot_jit_context && !IS_PGXC_COORDINATOR && JitExec::IsMotCodegenEnabled()) {
|
||||
int scan_ended = 0;
|
||||
if (!mot_finished_execution) {
|
||||
// previous iteration has not signaled end of scan
|
||||
|
||||
@ -233,6 +233,76 @@ select d.d1, sum(d.d2), sum(t.a2) from (select * from a union all select * from
|
||||
5 | 26 | 20
|
||||
(5 rows)
|
||||
|
||||
-- set parallel_workers of table a to 0, subplan of seqscan on a should not be paralleled
|
||||
alter table a set (parallel_workers=0);
|
||||
explain (costs off) select * from d left outer join (select * from a union all select * from b) as t on d.d1=t.a1 order by 1,2,3,4,5,6;
|
||||
QUERY PLAN
|
||||
------------------------------------------------
|
||||
Sort
|
||||
Sort Key: d.d1, d.d2, d.d3, a.a1, a.a2, a.a3
|
||||
-> Hash Right Join
|
||||
Hash Cond: (a.a1 = d.d1)
|
||||
-> Gather
|
||||
Number of Workers: 2
|
||||
-> Parallel Append
|
||||
-> Seq Scan on a
|
||||
-> Parallel Seq Scan on b
|
||||
-> Hash
|
||||
-> Gather
|
||||
Number of Workers: 1
|
||||
-> Parallel Seq Scan on d
|
||||
(13 rows)
|
||||
|
||||
explain (costs off) select d.d1, sum(d.d2), sum(t.a2) from (select * from a union all select * from b) t, d where t.a1=d1 group by d.d1 order by 1,2;
|
||||
QUERY PLAN
|
||||
------------------------------------------------------
|
||||
Sort
|
||||
Sort Key: d.d1, (sum(d.d2))
|
||||
-> HashAggregate
|
||||
Group By Key: d.d1
|
||||
-> Hash Join
|
||||
Hash Cond: (a.a1 = d.d1)
|
||||
-> Gather
|
||||
Number of Workers: 2
|
||||
-> Parallel Append
|
||||
-> Seq Scan on a
|
||||
-> Parallel Seq Scan on b
|
||||
-> Hash
|
||||
-> Gather
|
||||
Number of Workers: 1
|
||||
-> Parallel Seq Scan on d
|
||||
(15 rows)
|
||||
|
||||
select * from d left outer join (select * from a union all select * from b) as t on d.d1=t.a1 order by 1,2,3,4,5,6;
|
||||
d1 | d2 | d3 | a1 | a2 | a3
|
||||
----+----+----+----+----+----
|
||||
1 | 2 | 3 | 1 | 1 | 1
|
||||
1 | 3 | 2 | 1 | 1 | 1
|
||||
2 | 3 | 4 | 2 | 2 | 2
|
||||
2 | 4 | 4 | 2 | 2 | 2
|
||||
3 | 4 | 5 | 3 | 3 | 3
|
||||
3 | 5 | 6 | 3 | 3 | 3
|
||||
4 | 5 | 6 | 4 | 4 | 4
|
||||
4 | 5 | 6 | 4 | 4 | 4
|
||||
4 | 6 | 8 | 4 | 4 | 4
|
||||
4 | 6 | 8 | 4 | 4 | 4
|
||||
5 | 6 | 7 | 5 | 5 | 5
|
||||
5 | 6 | 7 | 5 | 5 | 5
|
||||
5 | 7 | 10 | 5 | 5 | 5
|
||||
5 | 7 | 10 | 5 | 5 | 5
|
||||
(14 rows)
|
||||
|
||||
select d.d1, sum(d.d2), sum(t.a2) from (select * from a union all select * from b) t, d where t.a1=d1 group by d.d1 order by 1,2;
|
||||
d1 | sum | sum
|
||||
----+-----+-----
|
||||
1 | 5 | 2
|
||||
2 | 7 | 4
|
||||
3 | 9 | 6
|
||||
4 | 22 | 16
|
||||
5 | 26 | 20
|
||||
(5 rows)
|
||||
|
||||
alter table a reset (parallel_workers);
|
||||
---------------------------------------
|
||||
-- 2. except && except all
|
||||
---------------------------------------
|
||||
|
||||
@ -31,6 +31,7 @@ select * from parallel_hashjoin_test_a left outer join parallel_hashjoin_test_b
|
||||
9 | 9
|
||||
(9 rows)
|
||||
|
||||
set force_parallel_mode=on;
|
||||
set parallel_setup_cost = 1;
|
||||
set min_parallel_table_scan_size=0;
|
||||
set parallel_tuple_cost = 0.01;
|
||||
@ -96,3 +97,4 @@ reset parallel_setup_cost;
|
||||
reset min_parallel_table_scan_size;
|
||||
reset parallel_tuple_cost;
|
||||
reset enable_nestloop;
|
||||
reset force_parallel_mode;
|
||||
|
||||
@ -25,6 +25,7 @@ select * from parallel_nested_loop_test_a left outer join parallel_nested_loop_t
|
||||
|
||||
set parallel_setup_cost = 0;
|
||||
set min_parallel_table_scan_size=0;
|
||||
set force_parallel_mode=on;
|
||||
explain (costs off) select * from parallel_nested_loop_test_a left outer join parallel_nested_loop_test_b on parallel_nested_loop_test_a.id = 1;
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------------
|
||||
@ -51,3 +52,4 @@ drop table parallel_nested_loop_test_a;
|
||||
drop table parallel_nested_loop_test_b;
|
||||
reset parallel_setup_cost;
|
||||
reset min_parallel_table_scan_size;
|
||||
reset force_parallel_mode;
|
||||
|
||||
@ -49,6 +49,13 @@ select * from (select * from a union all select * from b) as ta, c where ta.a1 =
|
||||
select * from d left outer join (select * from a union all select * from b) as t on d.d1=t.a1;
|
||||
select d.d1, sum(d.d2), sum(t.a2) from (select * from a union all select * from b) t, d where t.a1=d1 group by d.d1 order by 1,2;
|
||||
|
||||
-- set parallel_workers of table a to 0, subplan of seqscan on a should not be paralleled
|
||||
alter table a set (parallel_workers=0);
|
||||
explain (costs off) select * from d left outer join (select * from a union all select * from b) as t on d.d1=t.a1 order by 1,2,3,4,5,6;
|
||||
explain (costs off) select d.d1, sum(d.d2), sum(t.a2) from (select * from a union all select * from b) t, d where t.a1=d1 group by d.d1 order by 1,2;
|
||||
select * from d left outer join (select * from a union all select * from b) as t on d.d1=t.a1 order by 1,2,3,4,5,6;
|
||||
select d.d1, sum(d.d2), sum(t.a2) from (select * from a union all select * from b) t, d where t.a1=d1 group by d.d1 order by 1,2;
|
||||
alter table a reset (parallel_workers);
|
||||
|
||||
---------------------------------------
|
||||
-- 2. except && except all
|
||||
|
||||
@ -7,6 +7,7 @@ analyse parallel_hashjoin_test_b;
|
||||
explain (costs off) select * from parallel_hashjoin_test_a left outer join parallel_hashjoin_test_b on parallel_hashjoin_test_a.id = parallel_hashjoin_test_b.id where parallel_hashjoin_test_a.id < 10 order by parallel_hashjoin_test_a.id;
|
||||
select * from parallel_hashjoin_test_a left outer join parallel_hashjoin_test_b on parallel_hashjoin_test_a.id = parallel_hashjoin_test_b.id where parallel_hashjoin_test_a.id < 10 order by parallel_hashjoin_test_a.id;
|
||||
|
||||
set force_parallel_mode=on;
|
||||
set parallel_setup_cost = 1;
|
||||
set min_parallel_table_scan_size=0;
|
||||
set parallel_tuple_cost = 0.01;
|
||||
@ -22,4 +23,4 @@ reset parallel_setup_cost;
|
||||
reset min_parallel_table_scan_size;
|
||||
reset parallel_tuple_cost;
|
||||
reset enable_nestloop;
|
||||
|
||||
reset force_parallel_mode;
|
||||
|
||||
@ -9,6 +9,7 @@ select * from parallel_nested_loop_test_a left outer join parallel_nested_loop_t
|
||||
|
||||
set parallel_setup_cost = 0;
|
||||
set min_parallel_table_scan_size=0;
|
||||
set force_parallel_mode=on;
|
||||
|
||||
explain (costs off) select * from parallel_nested_loop_test_a left outer join parallel_nested_loop_test_b on parallel_nested_loop_test_a.id = 1;
|
||||
select * from parallel_nested_loop_test_a left outer join parallel_nested_loop_test_b on parallel_nested_loop_test_a.id = 1;
|
||||
@ -17,4 +18,5 @@ drop table parallel_nested_loop_test_a;
|
||||
drop table parallel_nested_loop_test_b;
|
||||
|
||||
reset parallel_setup_cost;
|
||||
reset min_parallel_table_scan_size;
|
||||
reset min_parallel_table_scan_size;
|
||||
reset force_parallel_mode;
|
||||
Reference in New Issue
Block a user