diff --git a/src/sql/optimizer/ob_join_order.cpp b/src/sql/optimizer/ob_join_order.cpp index b7cf23d1c6..651df32474 100644 --- a/src/sql/optimizer/ob_join_order.cpp +++ b/src/sql/optimizer/ob_join_order.cpp @@ -354,7 +354,7 @@ int ObJoinOrder::compute_sharding_info_for_base_paths(ObIArray &ac int ObJoinOrder::prune_paths_due_to_parallel(ObIArray &access_paths) { int ret = OB_SUCCESS; - if (access_paths.empty()) { + if (access_paths.count() < 2) { /* do nothing */ } else if (OB_ISNULL(access_paths.at(0)) || OB_ISNULL(get_plan())) { ret = OB_ERR_UNEXPECTED; @@ -366,7 +366,6 @@ int ObJoinOrder::prune_paths_due_to_parallel(ObIArray &access_path } else { ObSEArray tmp_paths; AccessPath *path = NULL; - AccessPath *default_path = NULL; // to reserve at least one path bool need_prune = false; for (int64_t i = 0; OB_SUCC(ret) && i < access_paths.count(); i++) { need_prune = false; @@ -375,30 +374,26 @@ int ObJoinOrder::prune_paths_due_to_parallel(ObIArray &access_path LOG_WARN("get unexpected null", K(path), K(ret)); } else if (!path->is_global_index_) { /* do nothing */ - } else if (!path->use_das_ && 1 >= path->parallel_) { - default_path = NULL == default_path ? path : default_path; - need_prune = true; - } else if (path->use_das_) { - AccessPath *cur_path = NULL; - for (int64_t j = 0; NULL == cur_path && j < access_paths.count(); ++j) { - if (i != j && NULL != access_paths.at(j) && path->index_id_ == access_paths.at(j)->index_id_) { - cur_path = access_paths.at(j); + } else { + AccessPath *target_path = NULL; + for (int64_t j = 0; NULL == target_path && j < access_paths.count(); ++j) { + if (i != j && NULL != access_paths.at(j) && path->index_id_ == access_paths.at(j)->index_id_ + && path->use_column_store_ == access_paths.at(j)->use_column_store_) { + target_path = access_paths.at(j); } } - need_prune = NULL != cur_path && cur_path->parallel_ > 1; + if (NULL != target_path) { + need_prune = path->use_das_ ? 1 < target_path->parallel_ + : 1 >= path->parallel_; + } } if (OB_SUCC(ret) && !need_prune && OB_FAIL(tmp_paths.push_back(path))) { LOG_WARN("failed to push back access path", K(ret)); } } - if (OB_FAIL(ret)) { - } else if (tmp_paths.count() == access_paths.count()) { - /* do nothing */ - } else if (OB_FAIL(access_paths.assign(tmp_paths))) { + if (OB_SUCC(ret) && tmp_paths.count() != access_paths.count() + && OB_FAIL(access_paths.assign(tmp_paths))) { LOG_WARN("failed to assign paths", K(ret)); - } else if (access_paths.empty() && NULL != default_path && !default_path->is_inner_path_ - && OB_FAIL(access_paths.push_back(default_path))) { - LOG_WARN("failed to push back access path", K(ret)); } } return ret; diff --git a/src/sql/optimizer/ob_log_plan.cpp b/src/sql/optimizer/ob_log_plan.cpp index 2ec609421e..86e407c432 100644 --- a/src/sql/optimizer/ob_log_plan.cpp +++ b/src/sql/optimizer/ob_log_plan.cpp @@ -7775,7 +7775,8 @@ int ObLogPlan::inner_candi_allocate_subplan_filter(ObIArray &subplan } else if (OB_FAIL(get_valid_subplan_filter_dist_method(subplans, for_cursor_expr, false, dist_methods))) { LOG_WARN("failed to get valid subplan filter dist method", K(ret)); - } else if (OB_FAIL(inner_candi_allocate_subplan_filter(best_subplan_list, + } else if (DIST_INVALID_METHOD != dist_methods && + OB_FAIL(inner_candi_allocate_subplan_filter(best_subplan_list, best_dist_subplan_list, query_refs, params, @@ -8020,7 +8021,7 @@ int ObLogPlan::inner_candi_allocate_subplan_filter(ObIArray= 0; j--) { + for (int64_t j = move_pos.count() - 1; !has_next && OB_SUCC(ret) && j >= 0; j--) { if (move_pos.at(j) < best_list.at(j).count() - 1) { ++move_pos.at(j); has_next = true; diff --git a/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/subplan_filter.result b/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/subplan_filter.result index 57b0bbf3f6..f0410b3883 100644 --- a/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/subplan_filter.result +++ b/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/subplan_filter.result @@ -2035,8 +2035,8 @@ Query Plan |2 |│ └─EXCHANGE OUT DISTR |:EX10000|18 |11 | |3 |│ └─PX PARTITION ITERATOR | |18 |5 | |4 |│ └─TABLE FULL SCAN |t1 |18 |5 | -|5 |├─TABLE RANGE SCAN |t2 |8 |18 | -|6 |└─DISTRIBUTED TABLE RANGE SCAN|t2 |8 |18 | +|5 |├─DISTRIBUTED TABLE RANGE SCAN|t2 |8 |18 | +|6 |└─TABLE RANGE SCAN |t2 |8 |18 | ================================================================== Outputs & filters: ------------------------------------- @@ -2079,8 +2079,8 @@ Outline Data: PQ_SUBQUERY(@"SEL$1" ("SEL$2" "SEL$3") LOCAL LOCAL) FULL(@"SEL$1" "test"."t1"@"SEL$1") FULL(@"SEL$2" "test"."t2"@"SEL$2") + USE_DAS(@"SEL$2" "test"."t2"@"SEL$2") FULL(@"SEL$3" "test"."t2"@"SEL$3") - USE_DAS(@"SEL$3" "test"."t2"@"SEL$3") OPTIMIZER_FEATURES_ENABLE('') END_OUTLINE_DATA */ @@ -2105,7 +2105,7 @@ Optimization Info: index_back_rows:0 output_rows:7 table_dop:1 - dop_method:Table DOP + dop_method:DAS DOP avaiable_index_name:[t2] stats version:0 dynamic sampling level:0 @@ -2117,7 +2117,7 @@ Optimization Info: index_back_rows:0 output_rows:7 table_dop:1 - dop_method:DAS DOP + dop_method:Table DOP avaiable_index_name:[t2] stats version:0 dynamic sampling level:0 @@ -2159,8 +2159,8 @@ Query Plan |2 |│ └─EXCHANGE OUT DISTR |:EX10000|18 |11 | |3 |│ └─PX PARTITION ITERATOR | |18 |5 | |4 |│ └─TABLE FULL SCAN |t1 |18 |5 | -|5 |├─TABLE RANGE SCAN |t2 |8 |18 | -|6 |└─DISTRIBUTED TABLE RANGE SCAN|t2 |8 |18 | +|5 |├─DISTRIBUTED TABLE RANGE SCAN|t2 |8 |18 | +|6 |└─TABLE RANGE SCAN |t2 |8 |18 | ================================================================== Outputs & filters: ------------------------------------- @@ -2203,8 +2203,8 @@ Outline Data: PQ_SUBQUERY(@"SEL$1" ("SEL$2" "SEL$3") LOCAL LOCAL) FULL(@"SEL$1" "test"."t1"@"SEL$1") FULL(@"SEL$2" "test"."t2"@"SEL$2") + USE_DAS(@"SEL$2" "test"."t2"@"SEL$2") FULL(@"SEL$3" "test"."t2"@"SEL$3") - USE_DAS(@"SEL$3" "test"."t2"@"SEL$3") OPTIMIZER_FEATURES_ENABLE('') END_OUTLINE_DATA */ @@ -2229,7 +2229,7 @@ Optimization Info: index_back_rows:0 output_rows:7 table_dop:1 - dop_method:Table DOP + dop_method:DAS DOP avaiable_index_name:[t2] stats version:0 dynamic sampling level:0 @@ -2241,7 +2241,7 @@ Optimization Info: index_back_rows:0 output_rows:7 table_dop:1 - dop_method:DAS DOP + dop_method:Table DOP avaiable_index_name:[t2] stats version:0 dynamic sampling level:0 @@ -2283,8 +2283,8 @@ Query Plan |2 |│ └─EXCHANGE OUT DISTR |:EX10000|18 |11 | |3 |│ └─PX PARTITION ITERATOR | |18 |5 | |4 |│ └─TABLE FULL SCAN |t1 |18 |5 | -|5 |├─TABLE RANGE SCAN |t2 |8 |18 | -|6 |└─DISTRIBUTED TABLE RANGE SCAN|t2 |8 |18 | +|5 |├─DISTRIBUTED TABLE RANGE SCAN|t2 |8 |18 | +|6 |└─TABLE RANGE SCAN |t2 |8 |18 | ================================================================== Outputs & filters: ------------------------------------- @@ -2327,8 +2327,8 @@ Outline Data: PQ_SUBQUERY(@"SEL$1" ("SEL$2" "SEL$3") LOCAL LOCAL) FULL(@"SEL$1" "test"."t1"@"SEL$1") FULL(@"SEL$2" "test"."t2"@"SEL$2") + USE_DAS(@"SEL$2" "test"."t2"@"SEL$2") FULL(@"SEL$3" "test"."t2"@"SEL$3") - USE_DAS(@"SEL$3" "test"."t2"@"SEL$3") OPTIMIZER_FEATURES_ENABLE('') END_OUTLINE_DATA */ @@ -2353,7 +2353,7 @@ Optimization Info: index_back_rows:0 output_rows:7 table_dop:1 - dop_method:Table DOP + dop_method:DAS DOP avaiable_index_name:[t2] stats version:0 dynamic sampling level:0 @@ -2365,7 +2365,7 @@ Optimization Info: index_back_rows:0 output_rows:7 table_dop:1 - dop_method:DAS DOP + dop_method:Table DOP avaiable_index_name:[t2] stats version:0 dynamic sampling level:0 @@ -2407,8 +2407,8 @@ Query Plan |2 |│ └─EXCHANGE OUT DISTR |:EX10000|18 |11 | |3 |│ └─PX PARTITION ITERATOR | |18 |5 | |4 |│ └─TABLE FULL SCAN |t1 |18 |5 | -|5 |├─TABLE RANGE SCAN |t2 |8 |18 | -|6 |└─DISTRIBUTED TABLE RANGE SCAN|t2 |8 |18 | +|5 |├─DISTRIBUTED TABLE RANGE SCAN|t2 |8 |18 | +|6 |└─TABLE RANGE SCAN |t2 |8 |18 | ================================================================== Outputs & filters: ------------------------------------- @@ -2451,8 +2451,8 @@ Outline Data: PQ_SUBQUERY(@"SEL$1" ("SEL$2" "SEL$3") LOCAL LOCAL) FULL(@"SEL$1" "test"."t1"@"SEL$1") FULL(@"SEL$2" "test"."t2"@"SEL$2") + USE_DAS(@"SEL$2" "test"."t2"@"SEL$2") FULL(@"SEL$3" "test"."t2"@"SEL$3") - USE_DAS(@"SEL$3" "test"."t2"@"SEL$3") OPTIMIZER_FEATURES_ENABLE('') END_OUTLINE_DATA */ @@ -2477,7 +2477,7 @@ Optimization Info: index_back_rows:0 output_rows:7 table_dop:1 - dop_method:Table DOP + dop_method:DAS DOP avaiable_index_name:[t2] stats version:0 dynamic sampling level:0 @@ -2489,7 +2489,7 @@ Optimization Info: index_back_rows:0 output_rows:7 table_dop:1 - dop_method:DAS DOP + dop_method:Table DOP avaiable_index_name:[t2] stats version:0 dynamic sampling level:0 @@ -2531,9 +2531,9 @@ Query Plan |2 |│ └─EXCHANGE OUT DISTR |:EX10000|18 |11 | |3 |│ └─PX PARTITION ITERATOR | |18 |5 | |4 |│ └─TABLE FULL SCAN |t1 |18 |5 | -|5 |├─TABLE RANGE SCAN |t2 |8 |18 | +|5 |├─DISTRIBUTED TABLE RANGE SCAN|t2 |8 |18 | |6 |├─DISTRIBUTED TABLE RANGE SCAN|t2 |8 |18 | -|7 |└─DISTRIBUTED TABLE GET |t2 |1 |18 | +|7 |└─TABLE GET |t2 |1 |18 | ================================================================== Outputs & filters: ------------------------------------- @@ -2582,10 +2582,10 @@ Outline Data: PQ_SUBQUERY(@"SEL$1" ("SEL$2" "SEL$3" "SEL$4") LOCAL LOCAL) FULL(@"SEL$1" "test"."t1"@"SEL$1") FULL(@"SEL$2" "test"."t2"@"SEL$2") + USE_DAS(@"SEL$2" "test"."t2"@"SEL$2") FULL(@"SEL$3" "test"."t2"@"SEL$3") USE_DAS(@"SEL$3" "test"."t2"@"SEL$3") FULL(@"SEL$4" "test"."t2"@"SEL$4") - USE_DAS(@"SEL$4" "test"."t2"@"SEL$4") OPTIMIZER_FEATURES_ENABLE('') END_OUTLINE_DATA */ @@ -2610,7 +2610,7 @@ Optimization Info: index_back_rows:0 output_rows:7 table_dop:1 - dop_method:Table DOP + dop_method:DAS DOP avaiable_index_name:[t2] stats version:0 dynamic sampling level:0 @@ -2634,7 +2634,7 @@ Optimization Info: index_back_rows:0 output_rows:1 table_dop:1 - dop_method:DAS DOP + dop_method:Table DOP avaiable_index_name:[t2] stats version:0 dynamic sampling level:0