From 82418cf2259b90ec2288ee6903eb9378ce348a4e Mon Sep 17 00:00:00 2001 From: zzg19950727 <1071026277@qq.com> Date: Tue, 21 Nov 2023 15:14:59 +0000 Subject: [PATCH] fix some sql logical plan bug --- src/sql/monitor/ob_sql_plan.cpp | 137 +++++++++++++++--- src/sql/monitor/ob_sql_plan.h | 14 +- src/sql/ob_optimizer_trace_impl.cpp | 84 ++++++++++- src/sql/ob_optimizer_trace_impl.h | 22 ++- src/sql/ob_sql.cpp | 15 ++ .../optimizer/ob_access_path_estimation.cpp | 6 +- src/sql/optimizer/ob_explain_log_plan.cpp | 1 + src/sql/optimizer/ob_log_plan.cpp | 3 + src/sql/optimizer/ob_log_plan.h | 22 --- 9 files changed, 257 insertions(+), 47 deletions(-) diff --git a/src/sql/monitor/ob_sql_plan.cpp b/src/sql/monitor/ob_sql_plan.cpp index fddeb182ab..9d93e3b563 100644 --- a/src/sql/monitor/ob_sql_plan.cpp +++ b/src/sql/monitor/ob_sql_plan.cpp @@ -73,7 +73,8 @@ namespace sql { ObSqlPlan::ObSqlPlan(common::ObIAllocator &allocator) - :allocator_(allocator) + :allocator_(allocator), + session_(NULL) { } @@ -151,13 +152,10 @@ int ObSqlPlan::store_sql_plan_for_explain(ObExecContext *ctx, } } if (OB_SUCC(ret)) { - if (allocate_mem_failed) { + if (allocate_mem_failed || plan_strs.empty()) { if (OB_FAIL(plan_strs.push_back("Plan truncated due to insufficient memory!"))) { LOG_WARN("failed to push back string", K(ret)); } - } else if (plan_strs.empty()) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("failed to generate plan", K(ret)); } } destroy_buffer(plan_text); @@ -229,6 +227,39 @@ int ObSqlPlan::get_plan_outline_info_one_line(PlanText &plan_text, return ret; } +int ObSqlPlan::get_plan_used_hint_info_one_line(PlanText &plan_text, + ObLogPlan* plan) +{ + int ret = OB_SUCCESS; + const ObQueryCtx *query_ctx = NULL; + if (OB_ISNULL(plan) || + OB_ISNULL(query_ctx = plan->get_optimizer_context().get_query_ctx())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected NULL", K(ret), K(plan), K(query_ctx)); + } else { + const ObQueryHint &query_hint = query_ctx->get_query_hint(); + plan_text.is_used_hint_ = true; + plan_text.is_oneline_ = true; + plan_text.pos_ = 0; + BUF_PRINT_CONST_STR("/*+ ", plan_text); + if (OB_FAIL(get_plan_tree_used_hint(plan_text, plan->get_plan_root()))) { + LOG_WARN("failed to get plan tree used hint", K(ret)); + } else if (OB_FAIL(query_hint.print_qb_name_hints(plan_text))) { + LOG_WARN("failed to print qb name hints", K(ret)); + } else if (OB_FAIL(query_hint.print_transform_hints(plan_text))) { + LOG_WARN("failed to print all transform hints", K(ret)); + } else if (OB_FAIL(query_hint.get_global_hint().print_global_hint(plan_text))) { + LOG_WARN("failed to print global hint", K(ret)); + } else { + BUF_PRINT_CONST_STR(" */", plan_text); + } + if (OB_SIZE_OVERFLOW == ret) { + ret = OB_SUCCESS; + } + } + return ret; +} + int ObSqlPlan::get_global_hint_outline(PlanText &plan_text, ObLogPlan &plan) { int ret = OB_SUCCESS; @@ -1046,10 +1077,12 @@ int ObSqlPlan::print_constraint_info(char *buf, int ObSqlPlan::format_sql_plan(ObIArray &sql_plan_infos, ExplainType type, const ObExplainDisplayOpt& option, - PlanText &plan_text) + PlanText &plan_text, + const bool alloc_buffer) { int ret = OB_SUCCESS; - if (OB_FAIL(init_buffer(plan_text))) { + if (alloc_buffer && + OB_FAIL(init_buffer(plan_text))) { LOG_WARN("failed to init buffer", K(ret)); } else if (sql_plan_infos.empty()) { //do nothing @@ -1168,7 +1201,11 @@ int ObSqlPlan::get_plan_table_formatter(ObIArray &sql_plan_infos } //EST ROWS if (OB_SUCC(ret)) { - snprintf(buffer, sizeof(buffer), "%ld", plan_item->cardinality_); + if (plan_item->cardinality_ >= 0) { + snprintf(buffer, sizeof(buffer), "%ld", plan_item->cardinality_); + } else { + snprintf(buffer, sizeof(buffer), "%s", "more than 1.0e19"); + } length = (int32_t) strlen(buffer); if (length > format_helper.column_len_.at(EstRows)) { format_helper.column_len_.at(EstRows) = length; @@ -1176,7 +1213,11 @@ int ObSqlPlan::get_plan_table_formatter(ObIArray &sql_plan_infos } //EST COST if (OB_SUCC(ret)) { - snprintf(buffer, sizeof(buffer), "%ld", plan_item->cost_); + if (plan_item->cost_ >= 0) { + snprintf(buffer, sizeof(buffer), "%ld", plan_item->cost_); + } else { + snprintf(buffer, sizeof(buffer), "%s", "more than 1.0e19"); + } length = (int32_t) strlen(buffer); if (length > format_helper.column_len_.at(EstCost)) { format_helper.column_len_.at(EstCost) = length; @@ -1230,7 +1271,11 @@ int ObSqlPlan::get_real_plan_table_formatter(ObIArray &sql_plan_ } //EST ROWS if (OB_SUCC(ret)) { - snprintf(buffer, sizeof(buffer), "%ld", plan_item->cardinality_); + if (plan_item->cardinality_ >= 0) { + snprintf(buffer, sizeof(buffer), "%ld", plan_item->cardinality_); + } else { + snprintf(buffer, sizeof(buffer), "%s", "more than 1.0e19"); + } length = (int32_t) strlen(buffer); if (length > format_helper.column_len_.at(EstRows)) { format_helper.column_len_.at(EstRows) = length; @@ -1238,7 +1283,11 @@ int ObSqlPlan::get_real_plan_table_formatter(ObIArray &sql_plan_ } //EST COST if (OB_SUCC(ret)) { - snprintf(buffer, sizeof(buffer), "%ld", plan_item->cost_); + if (plan_item->cost_ >= 0) { + snprintf(buffer, sizeof(buffer), "%ld", plan_item->cost_); + } else { + snprintf(buffer, sizeof(buffer), "%s", "more than 1.0e19"); + } length = (int32_t) strlen(buffer); if (length > format_helper.column_len_.at(EstCost)) { format_helper.column_len_.at(EstCost) = length; @@ -1431,13 +1480,13 @@ int ObSqlPlan::get_operator_prefix(ObIArray &sql_plan_infos, ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpect idx", K(ret)); } else if (prefix_helper.with_line_.at(j)) { - const char *txt = "│ "; + const char *txt = get_tree_line(0); if (plan_item->parent_id_ == parent_item->id_) { if (plan_item->is_last_child_) { - txt = "└─"; + txt = get_tree_line(1); prefix_helper.with_line_.at(j) = false; } else { - txt = "├─"; + txt = get_tree_line(2); } } if (prefix_helper.color_idxs_.at(j) >= 0) { @@ -1664,16 +1713,28 @@ int ObSqlPlan::format_plan_table(ObIArray &sql_plan_infos, //ROWS if (OB_SUCC(ret)) { ret = BUF_PRINTF(COLUMN_SEPARATOR); - ret = BUF_PRINTF("%-*ld", + if (plan_item->cardinality_ >= 0) { + ret = BUF_PRINTF("%-*ld", format_helper.column_len_.at(EstRows), plan_item->cardinality_); + } else { + ret = BUF_PRINTF("%-*s", + format_helper.column_len_.at(EstRows), + "more than 1.0e19"); + } } //COST if (OB_SUCC(ret)) { ret = BUF_PRINTF(COLUMN_SEPARATOR); - ret = BUF_PRINTF("%-*ld", + if (plan_item->cost_ >= 0) { + ret = BUF_PRINTF("%-*ld", format_helper.column_len_.at(EstCost), plan_item->cost_); + } else { + ret = BUF_PRINTF("%-*s", + format_helper.column_len_.at(EstCost), + "more than 1.0e19"); + } ret = BUF_PRINTF(COLUMN_SEPARATOR); } if (OB_SUCC(ret)) { @@ -1781,16 +1842,28 @@ int ObSqlPlan::format_real_plan_table(ObIArray &sql_plan_infos, //EST ROWS if (OB_SUCC(ret)) { ret = BUF_PRINTF(COLUMN_SEPARATOR); - ret = BUF_PRINTF("%-*ld", + if (plan_item->cardinality_ >= 0) { + ret = BUF_PRINTF("%-*ld", format_helper.column_len_.at(EstRows), plan_item->cardinality_); + } else { + ret = BUF_PRINTF("%-*s", + format_helper.column_len_.at(EstRows), + "more than 1.0e19"); + } } //EST COST if (OB_SUCC(ret)) { ret = BUF_PRINTF(COLUMN_SEPARATOR); - ret = BUF_PRINTF("%-*ld", + if (plan_item->cost_ >= 0) { + ret = BUF_PRINTF("%-*ld", format_helper.column_len_.at(EstCost), plan_item->cost_); + } else { + ret = BUF_PRINTF("%-*s", + format_helper.column_len_.at(EstCost), + "more than 1.0e19"); + } } //REAL ROWS if (OB_SUCC(ret)) { @@ -2332,6 +2405,7 @@ int ObSqlPlan::init_buffer(PlanText &plan_text) { int ret = OB_SUCCESS; plan_text.buf_len_ = 1024 * 1024; + plan_text.pos_ = 0; plan_text.buf_ = static_cast(allocator_.alloc(plan_text.buf_len_)); if (OB_ISNULL(plan_text.buf_)) { ret = OB_ALLOCATE_MEMORY_FAILED; @@ -2459,5 +2533,32 @@ int ObSqlPlan::restore_session(ObSQLSessionInfo *session, return ret; } +const char* ObSqlPlan::get_tree_line(int type) +{ + static const char *tree_line[] = { + "│ ", + "└─", + "├─", + "| ", + "+-", + "|-" + }; + int ret = OB_SUCCESS; + ObCharsetType client_character = ObCharsetType::CHARSET_INVALID; + ObCharsetType connection_character = ObCharsetType::CHARSET_INVALID; + if (NULL == session_ || + OB_FAIL(session_->get_character_set_client(client_character)) || + OB_FAIL(session_->get_character_set_connection(connection_character))) { + return tree_line[type%3]; + } else if ((ObCharsetType::CHARSET_BINARY == client_character || + ObCharsetType::CHARSET_UTF8MB4 == client_character) && + (ObCharsetType::CHARSET_BINARY == connection_character || + ObCharsetType::CHARSET_UTF8MB4 == connection_character)) { + return tree_line[type%3]; + } else { + return tree_line[3+type%3]; + } +} + } // end of namespace sql } // end of namespace oceanbase diff --git a/src/sql/monitor/ob_sql_plan.h b/src/sql/monitor/ob_sql_plan.h index 8e237b863e..02bf434d8f 100644 --- a/src/sql/monitor/ob_sql_plan.h +++ b/src/sql/monitor/ob_sql_plan.h @@ -125,6 +125,7 @@ private: public: ObSqlPlan(common::ObIAllocator &allocator); virtual ~ObSqlPlan(); + void set_session_info(ObSQLSessionInfo *session) { session_ = session; } int store_sql_plan(ObLogPlan* log_plan, ObPhysicalPlan* phy_plan); int store_sql_plan_for_explain(ObExecContext *ctx, @@ -144,11 +145,15 @@ public: int format_sql_plan(ObIArray &sql_plan_infos, ExplainType type, const ObExplainDisplayOpt& option, - PlanText &plan_text); + PlanText &plan_text, + const bool alloc_buffer = true); static int get_plan_outline_info_one_line(PlanText &plan_text, ObLogPlan* plan); + static int get_plan_used_hint_info_one_line(PlanText &plan_text, + ObLogPlan* plan); + static int plan_text_to_string(PlanText &plan_text, common::ObString &plan_str); @@ -180,8 +185,8 @@ private: ObLogPlan* plan, ObSqlPlanItem* sql_plan_item); - int get_plan_tree_used_hint(PlanText &plan_text, - ObLogicalOperator* op); + static int get_plan_tree_used_hint(PlanText &plan_text, + ObLogicalOperator* op); int get_qb_name_trace(PlanText &plan_text, ObLogPlan* plan, @@ -282,6 +287,8 @@ private: transaction::ObTxDesc *tx_desc, int64_t nested_count); + const char* get_tree_line(int type); + public: static int format_one_output_expr(char *buf, int64_t buf_len, @@ -294,6 +301,7 @@ public: private: common::ObIAllocator &allocator_; + ObSQLSessionInfo *session_; }; } // end of namespace sql diff --git a/src/sql/ob_optimizer_trace_impl.cpp b/src/sql/ob_optimizer_trace_impl.cpp index b6a8be5c17..2ad219570c 100644 --- a/src/sql/ob_optimizer_trace_impl.cpp +++ b/src/sql/ob_optimizer_trace_impl.cpp @@ -30,6 +30,7 @@ #include "observer/omt/ob_tenant_config_mgr.h" #include "lib/file/file_directory_utils.h" #include "sql/session/ob_sql_session_info.h" +#include "sql/optimizer/ob_dynamic_sampling.h" using namespace oceanbase::common; using namespace oceanbase::share; @@ -407,7 +408,7 @@ int ObOptimizerTraceImpl::append(const ObObj& value) int64_t pos = 0; if (value.is_invalid_type()) { ret = append(" "); - } else if (OB_FAIL(value.print_smart(buf, buf_len, pos))) { + } else if (OB_FAIL(value.print_sql_literal(buf, buf_len, pos))) { LOG_WARN("failed to print obj", K(ret)); } else if (OB_FAIL(log_handle_.append(buf, pos))) { LOG_WARN("failed to append value", K(ret)); @@ -727,6 +728,87 @@ int ObOptimizerTraceImpl::append(const CandidatePlan &plan) return ret; } +int ObOptimizerTraceImpl::append(const ObDSResultItem &ds_result) +{ + int ret = OB_SUCCESS; + const ObOptDSStat *stat = ds_result.stat_handle_.stat_; + if (NULL == stat) { + } else if (OB_FAIL(append("table id:", ds_result.index_id_))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_DS_BASIC_STAT == ds_result.type_ && + OB_FAIL(append(", tpye:basic"))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_DS_OUTPUT_STAT == ds_result.type_ && + OB_FAIL(append(", tpye:output"))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_DS_FILTER_OUTPUT_STAT == ds_result.type_ && + OB_FAIL(append(", tpye:filter and output"))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FALSE_IT(increase_section())) { + } else if (OB_FAIL(new_line())) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(append("rows:", + stat->get_rowcount()))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(new_line())) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(append("macro_block_num:", + stat->get_macro_block_num()))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(new_line())) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(append("micro_block_num:", + stat->get_micro_block_num()))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(new_line())) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(append("sample_block_ratio:", + stat->get_sample_block_ratio()))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(new_line())) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(append("ds_level:", + stat->get_ds_level()))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(new_line())) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(append("dml_cnt:", + stat->get_dml_cnt()))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(new_line())) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(append("ds_degree:", + stat->get_ds_degree()))) { + LOG_WARN("failed to append msg", K(ret)); + } else { + for (int64_t j = 0; OB_SUCC(ret) && j < stat->get_ds_col_stats().count(); ++j) { + const ObOptDSColStat &col_stat = stat->get_ds_col_stats().at(j); + if (OB_FAIL(append("column id:", col_stat.column_id_, ":"))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FALSE_IT(increase_section())) { + } else if (OB_FAIL(new_line())) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(append("NDV:", col_stat.num_distinct_))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(new_line())) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(append("Null:", col_stat.num_null_))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(new_line())) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(append("degree:", col_stat.degree_))) { + LOG_WARN("failed to append msg", K(ret)); + } else if (OB_FAIL(new_line())) { + LOG_WARN("failed to append msg", K(ret)); + } else { + decrease_section(); + } + } + decrease_section(); + } + return ret; +} + int ObOptimizerTraceImpl::trace_env() { int ret = OB_SUCCESS; diff --git a/src/sql/ob_optimizer_trace_impl.h b/src/sql/ob_optimizer_trace_impl.h index 53a335293b..25b19ebe03 100644 --- a/src/sql/ob_optimizer_trace_impl.h +++ b/src/sql/ob_optimizer_trace_impl.h @@ -26,6 +26,7 @@ namespace oceanbase { namespace common { class ObObj; +class ObDSResultItem; } using namespace common; namespace sql @@ -163,7 +164,6 @@ inline ObOptimizerTraceImpl** get_local_tracer() #define OPT_TRACE_STATIS(stmt, table_metas) \ do { \ CHECK_TRACE_ENABLED { \ - tracer->append_title("BASIC TABLE STATIS"); \ tracer->trace_static(stmt, table_metas); \ } \ } while (0); \ @@ -264,6 +264,7 @@ public: int append(const TableItem *table); int append(const ObShardingInfo *info); int append(const CandidatePlan &plan); + int append(const ObDSResultItem &ds_result); /***********************************************/ ////print template type /***********************************************/ @@ -292,6 +293,11 @@ public: typename std::enable_if, T>::value, int>::type append(const T& value); + //for ObIArray + template + typename std::enable_if, T>::value, int>::type + append(const T& value); + //template for function append template int append(const T1& value1, const T2& value2, const ARGS&... args); @@ -423,6 +429,20 @@ ObOptimizerTraceImpl::append(const T& value) return ret; } +//for ObIArray +template +typename std::enable_if, T>::value, int>::type +ObOptimizerTraceImpl::append(const T& value) +{ + int ret = OB_SUCCESS; + for (int i = 0; OB_SUCC(ret) && i < value.count(); ++i) { + if (OB_FAIL(append(value.at(i)))) { + } else if (OB_FAIL(new_line())) { + } + } + return ret; +} + //template for function append template int ObOptimizerTraceImpl::append(const T1& value1, const T2& value2, const ARGS&... args) diff --git a/src/sql/ob_sql.cpp b/src/sql/ob_sql.cpp index a0815ab734..d7cb0ae761 100644 --- a/src/sql/ob_sql.cpp +++ b/src/sql/ob_sql.cpp @@ -3350,6 +3350,21 @@ int ObSql::prepare_outline_for_phy_plan(ObLogPlan *logical_plan, phy_plan->stat_.outline_data_.assign_ptr(buf, static_cast(plan_text.pos_)); } } + if (OB_FAIL(ret)) { + } else if (OB_UNLIKELY(NULL == (tmp_ptr = phy_plan->get_allocator().alloc(OB_MAX_SQL_LENGTH)))) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_ERROR("fail to alloc memory", K(ret)); + } else if (FALSE_IT(buf = static_cast(tmp_ptr))) { + } else { + PlanText plan_text; + plan_text.buf_ = buf; + plan_text.buf_len_ = OB_MAX_SQL_LENGTH; + if (OB_FAIL(ObSqlPlan::get_plan_used_hint_info_one_line(plan_text, logical_plan))) { + LOG_WARN("failed to get plan used hint info", K(ret)); + } else { + phy_plan->stat_.hints_info_.assign_ptr(buf, static_cast(plan_text.pos_)); + } + } return ret; } diff --git a/src/sql/optimizer/ob_access_path_estimation.cpp b/src/sql/optimizer/ob_access_path_estimation.cpp index 80307fefc3..ecf15ddd8b 100644 --- a/src/sql/optimizer/ob_access_path_estimation.cpp +++ b/src/sql/optimizer/ob_access_path_estimation.cpp @@ -1350,7 +1350,6 @@ int ObAccessPathEstimation::process_dynamic_sampling_estimation(ObOptimizerConte { int ret = OB_SUCCESS; LOG_TRACE("begin process dynamic sampling estimation", K(paths), K(is_inner_path)); - OPT_TRACE("begin to process table dynamic sampling estimation"); ObDSTableParam ds_table_param; ObSEArray ds_result_items; bool only_ds_basic_stat = false; @@ -1382,6 +1381,7 @@ int ObAccessPathEstimation::process_dynamic_sampling_estimation(ObOptimizerConte } else if (!only_ds_basic_stat && ds_paths.empty()) { //do nothing } else { + OPT_TRACE("begin to process table dynamic sampling estimation"); ObArenaAllocator allocator("ObOpTableDS", OB_MALLOC_NORMAL_BLOCK_SIZE, ctx.get_session_info()->get_effective_tenant_id()); ObDynamicSampling dynamic_sampling(ctx, allocator); int64_t start_time = ObTimeUtility::current_time(); @@ -1414,8 +1414,10 @@ int ObAccessPathEstimation::process_dynamic_sampling_estimation(ObOptimizerConte is_inner_path, ds_result_items))) { LOG_WARN("failed to estimate path rowcount by dynamic sampling", K(ret)); } + OPT_TRACE("end to process table dynamic sampling estimation"); + OPT_TRACE_TITLE("DYNAMIC SAMPLE RESULT"); + OPT_TRACE(ds_result_items); } - OPT_TRACE("end to process table dynamic sampling estimation"); return ret; } diff --git a/src/sql/optimizer/ob_explain_log_plan.cpp b/src/sql/optimizer/ob_explain_log_plan.cpp index 9b44ffcd40..729e9a6d0c 100644 --- a/src/sql/optimizer/ob_explain_log_plan.cpp +++ b/src/sql/optimizer/ob_explain_log_plan.cpp @@ -70,6 +70,7 @@ int ObExplainLogPlan::generate_normal_raw_plan() values_op = static_cast(top); values_op->set_explain_plan(child_plan); ObSqlPlan sql_plan(get_allocator()); + sql_plan.set_session_info(get_optimizer_context().get_session_info()); ObExplainLogPlan *explain_plan = static_cast(child_plan); ObSEArray plan_strs; const ObString& into_table = explain_stmt->get_into_table(); diff --git a/src/sql/optimizer/ob_log_plan.cpp b/src/sql/optimizer/ob_log_plan.cpp index 58ef9a1219..f3468d0960 100644 --- a/src/sql/optimizer/ob_log_plan.cpp +++ b/src/sql/optimizer/ob_log_plan.cpp @@ -793,7 +793,10 @@ int ObLogPlan::generate_join_orders() //如果有leading hint就在这里按leading hint指定的join order枚举, //如果根据leading hint没有枚举到有效join order,就忽略hint重新枚举。 if (OB_SUCC(ret)) { + OPT_TRACE_TITLE("BASIC TABLE STATISTICS"); OPT_TRACE_STATIS(stmt, get_basic_table_metas()); + OPT_TRACE_TITLE("UPDATE TABLE STATISTICS"); + OPT_TRACE_STATIS(stmt, get_update_table_metas()); OPT_TRACE_TITLE("START GENERATE JOIN ORDER"); if (OB_FAIL(init_bushy_tree_info(from_table_items))) { LOG_WARN("failed to init bushy tree infos", K(ret)); diff --git a/src/sql/optimizer/ob_log_plan.h b/src/sql/optimizer/ob_log_plan.h index 8463c1eb16..de78440a67 100644 --- a/src/sql/optimizer/ob_log_plan.h +++ b/src/sql/optimizer/ob_log_plan.h @@ -1486,28 +1486,6 @@ protected: const ObIArray &table_items, const ObIArray &join_conditions); - int init_leading_info_from_joined_tables(TableItem *table); - - int init_leading_info_from_tables(const ObIArray &table_items, - const ObIArray &semi_infos); - - int find_join_order_pair(uint8_t beg_pos, - uint8_t &end_pos, - uint8_t ignore_beg_pos, - uint8_t &ignore_end_pos, - bool &found); - - int get_table_ids_from_leading(uint8_t pos, ObRelIds& table_ids); - - int init_leading_info_from_leading_pair(uint8_t beg_pos, - uint8_t end_pos, - ObRelIds &table_set); - - int init_leading_info_from_leading(); - - int init_leading_info(const ObIArray &table_items, - const ObIArray &semi_infos); - int init_bushy_tree_info(const ObIArray &table_items); int init_bushy_tree_info_from_joined_tables(TableItem *table);