From b119e2ccdab4827da2c2652a8c475676324fb30a Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 30 Apr 2024 08:23:10 +0000 Subject: [PATCH] [CP] Fix: fix the bug induced by tracepoint to generate NLJ path --- src/sql/optimizer/ob_join_order.cpp | 38 ++++++----------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/src/sql/optimizer/ob_join_order.cpp b/src/sql/optimizer/ob_join_order.cpp index c3100b583..c26f50b7f 100644 --- a/src/sql/optimizer/ob_join_order.cpp +++ b/src/sql/optimizer/ob_join_order.cpp @@ -11835,9 +11835,10 @@ int ObJoinOrder::get_valid_path_info(const ObJoinOrder &left_tree, if (OB_SUCC(ret)) { bool force_use_nlj = false; force_use_nlj = (OB_SUCCESS != (OB_E(EventTable::EN_GENERATE_PLAN_WITH_NLJ) OB_SUCCESS)); - //if tracepoint is triggered and the local methiods contain NLJ, remove the merge-join paths to use nlj as possible + //if tracepoint is triggered and the local methiods contain NLJ, remove the merge-join and hash-join to use nlj as possible if (force_use_nlj && (path_info.local_methods_ & NESTED_LOOP_JOIN)) { path_info.local_methods_ &= ~MERGE_JOIN; + path_info.local_methods_ &= ~HASH_JOIN; } } //check batch update join type @@ -12665,36 +12666,11 @@ int ObJoinOrder::create_and_add_nl_path(const Path *left_path, } else if (OB_FAIL(create_subplan_filter_for_join_path(join_path, subquery_filters))) { LOG_WARN("failed to create subplan filter for join path", K(ret)); - } - - if (OB_SUCC(ret)) { - bool force_use_nlj = false; - // Trace point to force use NLJ as possible - force_use_nlj = (OB_SUCCESS != (OB_E(EventTable::EN_GENERATE_PLAN_WITH_NLJ) OB_SUCCESS)); - if (force_use_nlj && !join_path->contain_normal_nl_) { - // If the tracepoint is triggered, the nlj path is forced to add into interesting_paths, - // and other paths of different join types are removed - LOG_TRACE("trigger trace point to generate nest-loop join paths"); - if (join_path->join_algo_ != NESTED_LOOP_JOIN) { - LOG_WARN("generated join type is not NLJ", K(ret)); - } else if (OB_FAIL(interesting_paths_.push_back(join_path))) { - LOG_WARN("failed to push back nlj path"); - } else { - for (int64_t i = interesting_paths_.count() - 1; OB_SUCC(ret) && i >= 0; --i) { - JoinPath *join_path = reinterpret_cast(interesting_paths_.at(i)); - if (join_path->join_algo_ != NESTED_LOOP_JOIN) { - if (OB_FAIL(interesting_paths_.remove(i))) { - LOG_WARN("failed to remove dominated plans", K(i), K(ret)); - } - } - } - } - } else if (OB_FAIL(add_path(join_path))) { - LOG_WARN("failed to add path", K(ret)); - } else { - LOG_TRACE("succeed to create a nested loop join path", K(join_type), - K(join_dist_algo), K(need_mat), K(on_conditions), K(where_conditions)); - } + } else if (OB_FAIL(add_path(join_path))) { + LOG_WARN("failed to add path", K(ret)); + } else { + LOG_TRACE("succeed to create a nested loop join path", K(join_type), + K(join_dist_algo), K(need_mat), K(on_conditions), K(where_conditions)); } } return ret;