diff --git a/src/sql/optimizer/ob_log_set.cpp b/src/sql/optimizer/ob_log_set.cpp index 6dc55cff0f..152cd5ec07 100644 --- a/src/sql/optimizer/ob_log_set.cpp +++ b/src/sql/optimizer/ob_log_set.cpp @@ -850,10 +850,7 @@ int ObLogSet::construct_pq_set_hint(ObPQSetHint &hint) int ObLogSet::compute_op_parallel_and_server_info() { int ret = OB_SUCCESS; - bool is_partition_wise = DistAlgo::DIST_PARTITION_WISE == get_distributed_algo() - || DistAlgo::DIST_EXT_PARTITION_WISE == get_distributed_algo() - || DistAlgo::DIST_SET_PARTITION_WISE == get_distributed_algo(); - if (OB_FAIL(compute_normal_multi_child_parallel_and_server_info(is_partition_wise))) { + if (OB_FAIL(compute_normal_multi_child_parallel_and_server_info())) { LOG_WARN("failed to compute multi child parallel and server info", K(ret), K(get_distributed_algo())); } return ret; diff --git a/src/sql/optimizer/ob_log_subplan_filter.cpp b/src/sql/optimizer/ob_log_subplan_filter.cpp index 7b08000b0f..90988433a5 100644 --- a/src/sql/optimizer/ob_log_subplan_filter.cpp +++ b/src/sql/optimizer/ob_log_subplan_filter.cpp @@ -838,8 +838,7 @@ int ObLogSubPlanFilter::rebuild_repart_sharding_info(const ObShardingInfo *input int ObLogSubPlanFilter::compute_op_parallel_and_server_info() { int ret = OB_SUCCESS; - bool is_partition_wise = DistAlgo::DIST_PARTITION_WISE == get_distributed_algo(); - if (OB_FAIL(compute_normal_multi_child_parallel_and_server_info(is_partition_wise))) { + if (OB_FAIL(compute_normal_multi_child_parallel_and_server_info())) { LOG_WARN("failed to compute multi child parallel and server info", K(ret), K(get_distributed_algo())); } return ret; diff --git a/src/sql/optimizer/ob_logical_operator.cpp b/src/sql/optimizer/ob_logical_operator.cpp index 3e9101074d..68bc3d67a8 100644 --- a/src/sql/optimizer/ob_logical_operator.cpp +++ b/src/sql/optimizer/ob_logical_operator.cpp @@ -709,30 +709,31 @@ int ObLogicalOperator::compute_op_parallel_and_server_info() } -int ObLogicalOperator::compute_normal_multi_child_parallel_and_server_info(bool is_partition_wise) +int ObLogicalOperator::compute_normal_multi_child_parallel_and_server_info() { int ret = OB_SUCCESS; const ObLogicalOperator *max_parallel_child = NULL; - bool parallel_is_different = false; - int64_t op_parallel = ObGlobalHint::UNSET_PARALLEL; + bool max_parallel_from_exch = false; int64_t max_available_parallel = ObGlobalHint::DEFAULT_PARALLEL; const ObLogicalOperator *child = NULL; for (int64_t i = 0; OB_SUCC(ret) && i < get_num_of_child(); ++i) { if (OB_ISNULL(child = get_child(i))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("set operator i-th child is null", K(ret), K(i)); - } else if (child->is_match_all()) { - max_parallel_child = (NULL == max_parallel_child && (get_num_of_child() - 1) == i) - ? child : max_parallel_child; - } else if (ObGlobalHint::UNSET_PARALLEL == op_parallel) { - op_parallel = child->get_parallel(); + } else if (0 == i) { max_parallel_child = child; - max_available_parallel = child->get_available_parallel(); + max_available_parallel = max_parallel_child->get_available_parallel(); + max_parallel_from_exch = LOG_EXCHANGE == max_parallel_child->get_type(); + } else if (!max_parallel_from_exch && + LOG_EXCHANGE == child->get_type()) { + //do nothing } else { - parallel_is_different |= child->get_parallel() != op_parallel; - max_available_parallel = std::max(max_available_parallel, child->get_available_parallel()); - max_parallel_child = max_parallel_child->get_parallel() < child->get_parallel() - ? child : max_parallel_child; + if (max_parallel_child->get_parallel() < child->get_parallel() || + (max_parallel_from_exch && LOG_EXCHANGE != child->get_type())) { + max_available_parallel = child->get_available_parallel(); + max_parallel_child = child; + max_parallel_from_exch = LOG_EXCHANGE == max_parallel_child->get_type(); + } } } @@ -740,9 +741,6 @@ int ObLogicalOperator::compute_normal_multi_child_parallel_and_server_info(bool } else if (OB_ISNULL(max_parallel_child)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected null ", K(ret), K(max_parallel_child)); - } else if (OB_UNLIKELY(parallel_is_different && !is_partition_wise)) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("child op has different parallel except partition wise", K(ret)); } else if (OB_FAIL(get_server_list().assign(max_parallel_child->get_server_list()))) { LOG_WARN("failed to assign server list", K(ret)); } else { diff --git a/src/sql/optimizer/ob_logical_operator.h b/src/sql/optimizer/ob_logical_operator.h index 82d687dbe9..e6c6be35b4 100644 --- a/src/sql/optimizer/ob_logical_operator.h +++ b/src/sql/optimizer/ob_logical_operator.h @@ -1324,7 +1324,7 @@ public: virtual int compute_property(); int check_property_valid() const; - int compute_normal_multi_child_parallel_and_server_info(bool is_partition_wise); + int compute_normal_multi_child_parallel_and_server_info(); int set_parallel_and_server_info_for_match_all(); int get_limit_offset_value(ObRawExpr *percent_expr, ObRawExpr *limit_expr, diff --git a/src/sql/optimizer/ob_select_log_plan.cpp b/src/sql/optimizer/ob_select_log_plan.cpp index b2015674b3..49028d4766 100644 --- a/src/sql/optimizer/ob_select_log_plan.cpp +++ b/src/sql/optimizer/ob_select_log_plan.cpp @@ -2410,14 +2410,14 @@ int ObSelectLogPlan::check_sharding_inherit_from_access_all(ObLogicalOperator* o is_inherit_from_access_all = true; } } - if (OB_SUCC(ret) && - !is_inherit_from_access_all && - op->get_inherit_sharding_index() != -1) { - int64_t idx = op->get_inherit_sharding_index(); - if (idx < 0 || idx >= op->get_num_of_child()) { + for (int64_t i = 0; OB_SUCC(ret) && !is_inherit_from_access_all && i < op->get_num_of_child(); ++i) { + ObLogicalOperator *child = op->get_child(i); + if (OB_ISNULL(child)) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("unexpect inherit sharding index", K(ret)); - } else if (OB_FAIL(SMART_CALL(check_sharding_inherit_from_access_all(op->get_child(idx), + LOG_WARN("unexpect null child", K(ret), K(i)); + } else if (LOG_EXCHANGE == child->get_type()) { + //do nothing + } else if (OB_FAIL(SMART_CALL(check_sharding_inherit_from_access_all(child, is_inherit_from_access_all)))) { LOG_WARN("failed to check sharding inherit from bc2host", K(ret)); } diff --git a/src/sql/optimizer/ob_sharding_info.cpp b/src/sql/optimizer/ob_sharding_info.cpp index 37e6762b5e..59fee30812 100644 --- a/src/sql/optimizer/ob_sharding_info.cpp +++ b/src/sql/optimizer/ob_sharding_info.cpp @@ -1056,9 +1056,9 @@ int ObShardingInfo::is_sharding_equal(const ObShardingInfo *left_sharding, is_equal = false; } else if (left_sharding->get_location_type() != right_sharding->get_location_type()) { is_equal = false; - } else if (left_sharding->is_match_all() || left_sharding->is_local()) { - is_equal = true; - } else if (left_sharding->is_remote()) { + } else if (left_sharding->get_can_reselect_replica() != right_sharding->get_can_reselect_replica()) { + is_equal = false; + } else if (left_sharding->is_remote() || left_sharding->get_can_reselect_replica()) { ObSEArray left_servers; ObSEArray right_servers; if (OB_FAIL(get_serverlist_from_sharding(*left_sharding, left_servers))) { @@ -1070,6 +1070,8 @@ int ObShardingInfo::is_sharding_equal(const ObShardingInfo *left_sharding, is_equal))) { LOG_WARN("failed to check equal server list", K(ret)); } else { /*do nothing*/ } + } else if (left_sharding->is_match_all() || left_sharding->is_local()) { + is_equal = true; } else if (!ObOptimizerUtil::same_exprs(left_sharding->get_partition_keys(), right_sharding->get_partition_keys(), equal_sets) ||