From 0ca39e9932ef471aacfc4fb89aa3c00f9f44962a Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 8 Sep 2023 11:53:52 +0800 Subject: [PATCH] adjust auto dop --- src/sql/monitor/ob_sql_plan.cpp | 46 ++++++++++++++++-- src/sql/monitor/ob_sql_plan.h | 2 + src/sql/optimizer/ob_join_order.cpp | 59 ++++++++++-------------- src/sql/optimizer/ob_join_order.h | 6 +-- src/sql/optimizer/ob_optimizer.cpp | 55 ++++++++++++++-------- src/sql/optimizer/ob_optimizer_context.h | 46 ++++++++++++++---- src/sql/resolver/dml/ob_hint.cpp | 4 +- 7 files changed, 144 insertions(+), 74 deletions(-) diff --git a/src/sql/monitor/ob_sql_plan.cpp b/src/sql/monitor/ob_sql_plan.cpp index b64eb45298..009548fec9 100644 --- a/src/sql/monitor/ob_sql_plan.cpp +++ b/src/sql/monitor/ob_sql_plan.cpp @@ -13,6 +13,7 @@ #include "sql/resolver/ddl/ob_explain_stmt.h" #include "sql/optimizer/ob_log_values.h" #include "sql/optimizer/ob_log_plan.h" +#include "sql/optimizer/ob_del_upd_log_plan.h" #include "lib/time/Time.h" #include "pl/sys_package/ob_dbms_xplan.h" #include "lib/json/ob_json.h" @@ -208,8 +209,8 @@ int ObSqlPlan::get_plan_outline_info_one_line(PlanText &plan_text, LOG_WARN("failed to get plan tree outline", 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 if (OB_FAIL(get_global_hint_outline(plan_text, *plan))) { + LOG_WARN("failed to get plan global hint outline", K(ret)); } else { BUF_PRINT_CONST_STR(" END_OUTLINE_DATA*/", plan_text); plan_text.is_outline_data_ = false; @@ -221,6 +222,43 @@ int ObSqlPlan::get_plan_outline_info_one_line(PlanText &plan_text, return ret; } +int ObSqlPlan::get_global_hint_outline(PlanText &plan_text, ObLogPlan &plan) +{ + int ret = OB_SUCCESS; + ObGlobalHint outline_global_hint; + if (OB_FAIL(outline_global_hint.assign(plan.get_optimizer_context().get_global_hint()))) { + LOG_WARN("failed to assign global hint", K(ret)); + } else if (OB_FAIL(construct_outline_global_hint(plan, outline_global_hint))) { + LOG_WARN("failed to construct outline global hint", K(ret)); + } else if (OB_FAIL(outline_global_hint.print_global_hint(plan_text))) { + LOG_WARN("failed to print global hint", K(ret)); + } + return ret; +} + +int ObSqlPlan::construct_outline_global_hint(ObLogPlan &plan, ObGlobalHint &outline_global_hint) +{ + int ret = OB_SUCCESS; + ObDelUpdLogPlan *del_upd_plan = NULL; + outline_global_hint.opt_features_version_ = ObGlobalHint::CURRENT_OUTLINE_ENABLE_VERSION; + outline_global_hint.pdml_option_ = ObPDMLOption::NOT_SPECIFIED; + if (OB_SUCC(ret) && NULL != (del_upd_plan = dynamic_cast(&plan)) + && del_upd_plan->use_pdml()) { + outline_global_hint.pdml_option_ = ObPDMLOption::ENABLE; + } + + if (OB_SUCC(ret)) { + outline_global_hint.parallel_ = ObGlobalHint::UNSET_PARALLEL; + if (plan.get_optimizer_context().is_use_auto_dop()) { + outline_global_hint.merge_parallel_hint(ObGlobalHint::SET_ENABLE_AUTO_DOP); + } else if (plan.get_optimizer_context().get_max_parallel() > ObGlobalHint::DEFAULT_PARALLEL) { + outline_global_hint.merge_parallel_hint(plan.get_optimizer_context().get_max_parallel()); + } + } + + return ret; +} + int ObSqlPlan::inner_store_sql_plan_for_explain(ObExecContext *ctx, const ObString& plan_table, const ObString& statement_id, @@ -716,8 +754,8 @@ int ObSqlPlan::get_plan_outline_info(PlanText &plan_text, LOG_WARN("failed to get plan tree outline", K(ret)); } else if (OB_FAIL(query_hint.print_transform_hints(temp_text))) { LOG_WARN("failed to print all transform hints", K(ret)); - } else if (OB_FAIL(query_hint.get_global_hint().print_global_hint(temp_text))) { - LOG_WARN("failed to print global hint", K(ret)); + } else if (OB_FAIL(get_global_hint_outline(temp_text, *plan))) { + LOG_WARN("failed to get plan global hint outline", K(ret)); } else { BUF_PRINT_CONST_STR(NEW_LINE, temp_text); BUF_PRINT_CONST_STR(OUTPUT_PREFIX, temp_text); diff --git a/src/sql/monitor/ob_sql_plan.h b/src/sql/monitor/ob_sql_plan.h index 24158da5b3..e93a45f0f4 100644 --- a/src/sql/monitor/ob_sql_plan.h +++ b/src/sql/monitor/ob_sql_plan.h @@ -188,6 +188,8 @@ private: static int get_plan_tree_outline(PlanText &plan_text, ObLogicalOperator* op); + static int get_global_hint_outline(PlanText &plan_text, ObLogPlan &plan); + static int construct_outline_global_hint(ObLogPlan &plan, ObGlobalHint &outline_global_hint); int get_plan_other_info(PlanText &plan_text, ObLogPlan* plan, diff --git a/src/sql/optimizer/ob_join_order.cpp b/src/sql/optimizer/ob_join_order.cpp index 1e51a86930..c44e8120cc 100644 --- a/src/sql/optimizer/ob_join_order.cpp +++ b/src/sql/optimizer/ob_join_order.cpp @@ -690,9 +690,8 @@ int ObJoinOrder::compute_access_path_parallel(ObIArray &access_pat parallel = ObGlobalHint::UNSET_PARALLEL; ObOptimizerContext *opt_ctx = NULL; ObSQLSessionInfo *session_info = NULL; - int64_t parallel_limit = ObGlobalHint::UNSET_PARALLEL; + int64_t cur_min_parallel = ObGlobalHint::UNSET_PARALLEL; if (OB_ISNULL(get_plan()) || OB_ISNULL(opt_ctx = &get_plan()->get_optimizer_context()) - || OB_UNLIKELY(ObGlobalHint::DEFAULT_PARALLEL > opt_ctx->get_parallel_degree_limit()) || OB_ISNULL(session_info = opt_ctx->get_session_info())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected params", K(ret), K(get_plan()), K(opt_ctx), K(session_info)); @@ -703,37 +702,29 @@ int ObJoinOrder::compute_access_path_parallel(ObIArray &access_pat parallel = ObGlobalHint::DEFAULT_PARALLEL; } else if (OB_FAIL(get_random_parallel(access_paths, parallel))) { LOG_WARN("failed to get random parallel", K(ret)); - } else { - parallel = std::min(parallel, opt_ctx->get_parallel_degree_limit()); } - LOG_TRACE("Auto DOP trace point", K(session_info->is_user_session()), - K(opt_ctx->get_parallel_degree_limit()), K(parallel)); - } else if (OB_FAIL(get_parallel_from_available_access_paths(parallel_limit))) { + LOG_TRACE("Auto DOP trace point", K(session_info->is_user_session()), K(parallel)); + } else if (OB_FAIL(get_parallel_from_available_access_paths(cur_min_parallel))) { LOG_WARN("failed to get parallel from available access paths", K(ret)); } else { - parallel_limit = (ObGlobalHint::DEFAULT_PARALLEL > parallel_limit || - parallel_limit > opt_ctx->get_parallel_degree_limit()) - ? opt_ctx->get_parallel_degree_limit() - : parallel_limit; - const int64_t cost_threshold = opt_ctx->get_parallel_min_scan_time_threshold(); - int64_t calc_parallel = parallel_limit; - int64_t cur_parallel = ObGlobalHint::UNSET_PARALLEL; + int64_t calc_parallel = ObGlobalHint::UNSET_PARALLEL; int64_t das_path_cnt = 0; AccessPath *path = NULL; + bool finish = false; OPT_TRACE_TITLE("begin compute auto dop for table"); - for (int64_t i = 0; calc_parallel > ObGlobalHint::DEFAULT_PARALLEL && OB_SUCC(ret) && i < access_paths.count(); i++) { + for (int64_t i = 0; !finish && OB_SUCC(ret) && i < access_paths.count(); i++) { if (OB_ISNULL(path = access_paths.at(i))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null", K(path), K(ret)); } else if (path->use_das_) { ++das_path_cnt; - } else if (OB_FAIL(path->compute_parallel_degree(parallel_limit, cost_threshold, cur_parallel))) { + } else if (OB_FAIL(path->compute_parallel_degree(cur_min_parallel, calc_parallel))) { LOG_WARN("failed to compute parallel degree", K(ret)); } else { - LOG_TRACE("finish compute one path parallel degree", K(i), K(cur_parallel), K(calc_parallel), - K(parallel_limit), K(path->table_id_), K(path->index_id_)); - calc_parallel = std::min(cur_parallel, calc_parallel); - parallel_limit = calc_parallel; + LOG_TRACE("finish compute one path parallel degree", K(i), K(cur_min_parallel), K(calc_parallel), + K(path->table_id_), K(path->index_id_)); + cur_min_parallel = calc_parallel; + finish = ObGlobalHint::DEFAULT_PARALLEL == calc_parallel; } } OPT_TRACE_TITLE("end compute auto dop for table"); @@ -4855,8 +4846,7 @@ int AccessPath::assign(const AccessPath &other, common::ObIAllocator *allocator) } // compute auto dop for access path -int AccessPath::compute_parallel_degree(const int64_t parallel_degree_limit, - const int64_t cost_threshold, +int AccessPath::compute_parallel_degree(const int64_t cur_min_parallel_degree, int64_t ¶llel) const { int ret = OB_SUCCESS; @@ -4866,12 +4856,10 @@ int AccessPath::compute_parallel_degree(const int64_t parallel_degree_limit, double cost_threshold_us = 0.0; int64_t cur_parallel_degree_limit = ObGlobalHint::UNSET_PARALLEL; int64_t server_cnt = 0; - if (use_das_ || parallel_degree_limit <= ObGlobalHint::DEFAULT_PARALLEL - || is_virtual_table(est_cost_info_.ref_table_id_) + if (use_das_ || is_virtual_table(est_cost_info_.ref_table_id_) || est_cost_info_.is_unique_) { parallel = ObGlobalHint::DEFAULT_PARALLEL; - } else if (OB_FAIL(check_and_prepare_estimate_parallel_params(parallel_degree_limit, - cost_threshold, + } else if (OB_FAIL(check_and_prepare_estimate_parallel_params(cur_min_parallel_degree, px_part_gi_min_part_per_dop, cost_threshold_us, server_cnt, @@ -4914,21 +4902,20 @@ int AccessPath::compute_parallel_degree(const int64_t parallel_degree_limit, } if (OB_FAIL(ret)) { - } else if (OB_UNLIKELY(ObGlobalHint::DEFAULT_PARALLEL > parallel || parallel_degree_limit < parallel)) { + } else if (OB_UNLIKELY(ObGlobalHint::DEFAULT_PARALLEL > parallel || cur_parallel_degree_limit < parallel)) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("get unexpected parallel result", K(ret), K(parallel_degree_limit), K(parallel)); + LOG_WARN("get unexpected parallel result", K(ret), K(cur_parallel_degree_limit), K(parallel)); } else { OPT_TRACE("finish compute one path parallel degree:", parallel); LOG_TRACE("finish compute parallel degree", K(phy_query_range_row_count_), K(query_range_row_count_), - K(parallel), K(parallel_degree_limit), K(cur_parallel_degree_limit), + K(parallel), K(cur_parallel_degree_limit), K(cost_threshold_us), K(px_cost), K(cost), K(pre_cost)); } } return ret; } -int AccessPath::check_and_prepare_estimate_parallel_params(const int64_t input_parallel_degree_limit, - const double cost_threshold_ms, +int AccessPath::check_and_prepare_estimate_parallel_params(const int64_t cur_min_parallel_degree, int64_t &px_part_gi_min_part_per_dop, double &cost_threshold_us, int64_t &server_cnt, @@ -4943,23 +4930,25 @@ int AccessPath::check_and_prepare_estimate_parallel_params(const int64_t input_p ObSQLSessionInfo *session_info = NULL; ObSEArray server_list; if (OB_ISNULL(table_partition_info_) || - OB_UNLIKELY(cost_threshold_ms < 1) || OB_ISNULL(parent_) || OB_ISNULL(parent_->get_plan()) || OB_ISNULL(opt_ctx = &parent_->get_plan()->get_optimizer_context()) || OB_ISNULL(session_info = opt_ctx->get_session_info())) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("get unexpected params", K(ret), K(table_partition_info_), K(cost_threshold_ms), K(parent_), K(session_info)); + LOG_WARN("get unexpected params", K(ret), K(table_partition_info_), K(parent_), K(session_info)); } else if (OB_FAIL(session_info->get_sys_variable(share::SYS_VAR__PX_MIN_GRANULES_PER_SLAVE, px_part_gi_min_part_per_dop))) { LOG_WARN("failed to get sys variable px min granule per slave", K(ret)); } else if (OB_FAIL(table_partition_info_->get_all_servers(server_list))) { LOG_WARN("failed to get all servers", K(ret)); } else { px_part_gi_min_part_per_dop = std::max(1L, px_part_gi_min_part_per_dop); - cost_threshold_us = 1000.0 * cost_threshold_ms; + cost_threshold_us = 1000.0 * std::max(10L, opt_ctx->get_parallel_min_scan_time_threshold()); server_cnt = server_list.count(); - cur_parallel_degree_limit = input_parallel_degree_limit; + cur_parallel_degree_limit = opt_ctx->get_parallel_degree_limit(server_cnt); const int64_t row_parallel_limit = std::floor(phy_query_range_row_count_ / ROW_COUNT_THRESHOLD_PER_DOP); const int64_t ss_scan_parallel_limit = std::floor(est_cost_info_.ss_prefix_ndv_); + if (cur_min_parallel_degree > ObGlobalHint::DEFAULT_PARALLEL && cur_min_parallel_degree < cur_parallel_degree_limit) { + cur_parallel_degree_limit = cur_min_parallel_degree; + } if (row_parallel_limit > ObGlobalHint::DEFAULT_PARALLEL && row_parallel_limit < cur_parallel_degree_limit) { cur_parallel_degree_limit = row_parallel_limit; } diff --git a/src/sql/optimizer/ob_join_order.h b/src/sql/optimizer/ob_join_order.h index 560839f048..b13a84c05d 100644 --- a/src/sql/optimizer/ob_join_order.h +++ b/src/sql/optimizer/ob_join_order.h @@ -627,11 +627,9 @@ struct EstimateCostInfo { const ObCostTableScanInfo &get_cost_table_scan_info() const { return est_cost_info_; } ObCostTableScanInfo &get_cost_table_scan_info() { return est_cost_info_; } - int compute_parallel_degree(const int64_t parallel_degree_limit, - const int64_t micro_block_threshold, + int compute_parallel_degree(const int64_t cur_min_parallel_degree, int64_t ¶llel) const; - int check_and_prepare_estimate_parallel_params(const int64_t input_parallel_degree_limit, - const double cost_threshold_ms, + int check_and_prepare_estimate_parallel_params(const int64_t cur_min_parallel_degree, int64_t &px_part_gi_min_part_per_dop, double &cost_threshold_us, int64_t &server_cnt, diff --git a/src/sql/optimizer/ob_optimizer.cpp b/src/sql/optimizer/ob_optimizer.cpp index a087c6ad04..bda13b681b 100644 --- a/src/sql/optimizer/ob_optimizer.cpp +++ b/src/sql/optimizer/ob_optimizer.cpp @@ -432,13 +432,14 @@ int ObOptimizer::check_pdml_enabled(const ObDMLStmt &stmt, // 3. decided by session variable: _enable_parallel_dml is true or _force_parallel_dml_dop > 1; int ret = OB_SUCCESS; ObSqlCtx *sql_ctx = NULL; + ObQueryCtx *query_ctx = NULL; bool can_use_pdml = true; bool session_enable_pdml = false; bool enable_auto_dop = false; uint64_t session_pdml_dop = ObGlobalHint::UNSET_PARALLEL; - if (OB_ISNULL(ctx_.get_exec_ctx())) { + if (OB_ISNULL(ctx_.get_exec_ctx()) || OB_ISNULL(query_ctx = ctx_.get_query_ctx())) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("unexpected null", K(ret), K(ctx_.get_exec_ctx())); + LOG_WARN("unexpected null", K(ret), K(ctx_.get_exec_ctx()), K(query_ctx)); } else if (OB_ISNULL(sql_ctx = ctx_.get_exec_ctx()->get_sql_ctx())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected null", K(ret), K(ctx_.get_exec_ctx())); @@ -464,7 +465,8 @@ int ObOptimizer::check_pdml_enabled(const ObDMLStmt &stmt, // do nothing } else if (ctx_.get_global_hint().get_pdml_option() == ObPDMLOption::ENABLE) { // 1. enable parallel dml by hint - } else if (ctx_.get_global_hint().get_pdml_option() == ObPDMLOption::DISABLE) { + } else if (ctx_.get_global_hint().get_pdml_option() == ObPDMLOption::DISABLE + || query_ctx->get_query_hint().has_outline_data()) { can_use_pdml = false; // 1. disable parallel dml by hint } else if (ctx_.get_global_hint().enable_auto_dop()) { // 2.1 enable parallel dml by auto dop @@ -735,7 +737,10 @@ int ObOptimizer::init_parallel_policy(ObDMLStmt &stmt, const ObSQLSessionInfo &s int64_t session_force_parallel_dop = ObGlobalHint::UNSET_PARALLEL; bool session_enable_auto_dop = false; bool session_enable_manual_dop = false; - if (ctx_.has_pl_udf()) { + if (OB_ISNULL(ctx_.get_query_ctx())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("query ctx is nul", K(ret)); + } else if (ctx_.has_pl_udf()) { //following above rule, but if stmt contain pl_udf, force das, parallel should be 1 ctx_.set_parallel_rule(PXParallelRule::PL_UDF_DAS_FORCE_SERIALIZE); } else if (ctx_.has_cursor_expression()) { @@ -749,6 +754,9 @@ int ObOptimizer::init_parallel_policy(ObDMLStmt &stmt, const ObSQLSessionInfo &s ctx_.set_parallel(ctx_.get_global_hint().get_parallel_degree()); } else if (ctx_.get_global_hint().enable_auto_dop()) { ctx_.set_parallel_rule(PXParallelRule::AUTO_DOP); + } else if (ctx_.get_query_ctx()->get_query_hint().has_outline_data()) { + ctx_.set_parallel_rule(PXParallelRule::MANUAL_HINT); + ctx_.set_parallel(ObGlobalHint::DEFAULT_PARALLEL); } else if (session.is_user_session() && !ctx_.get_global_hint().enable_manual_dop() && OB_FAIL(OB_E(EventTable::EN_ENABLE_AUTO_DOP_FORCE_PARALLEL_PLAN) OB_SUCCESS)) { ret = OB_SUCCESS; @@ -774,7 +782,7 @@ int ObOptimizer::init_parallel_policy(ObDMLStmt &stmt, const ObSQLSessionInfo &s } else { LOG_TRACE("succeed to init parallel policy", K(session.is_user_session()), K(ctx_.can_use_pdml()), K(ctx_.get_parallel_rule()), K(ctx_.get_parallel()), - K(ctx_.get_parallel_degree_limit()), K(ctx_.get_parallel_min_scan_time_threshold())); + K(ctx_.get_auto_dop_params())); } return ret; } @@ -782,31 +790,38 @@ int ObOptimizer::init_parallel_policy(ObDMLStmt &stmt, const ObSQLSessionInfo &s int ObOptimizer::set_auto_dop_params(const ObSQLSessionInfo &session) { int ret = OB_SUCCESS; - const uint64_t default_parallel_degree_limit = 256; - uint64_t parallel_degree_limit = default_parallel_degree_limit; + uint64_t parallel_degree_limit = 0; uint64_t parallel_min_scan_time_threshold = 1000; - int64_t parallel_servers_target = 0; + AutoDOPParams params; if (!session.is_user_session()) { /* do nothing */ } else if (OB_FAIL(session.get_sys_variable(share::SYS_VAR_PARALLEL_DEGREE_LIMIT, parallel_degree_limit))) { LOG_WARN("failed to get sys variable parallel degree limit", K(ret)); } else if (OB_FAIL(session.get_sys_variable(share::SYS_VAR_PARALLEL_MIN_SCAN_TIME_THRESHOLD, parallel_min_scan_time_threshold))) { LOG_WARN("failed to get sys variable parallel threshold", K(ret)); - } else if (0 != parallel_degree_limit) { - /* do nothing */ - } else if (OB_FAIL(ObSchemaUtils::get_tenant_int_variable(session.get_effective_tenant_id(), - SYS_VAR_PARALLEL_SERVERS_TARGET, - parallel_servers_target))) { - LOG_WARN("fail read tenant variable", K(ret), K(session.get_effective_tenant_id())); - } else if (parallel_servers_target > 0) { - parallel_degree_limit = parallel_servers_target; - } else { - parallel_degree_limit = default_parallel_degree_limit; + } + + if (OB_SUCC(ret) && 0 == parallel_degree_limit) { + const ObTenantBase *tenant = NULL; + int64_t parallel_servers_target = 0; + if (OB_ISNULL(tenant = MTL_CTX())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (session.is_user_session() && + OB_FAIL(ObSchemaUtils::get_tenant_int_variable(session.get_effective_tenant_id(), + SYS_VAR_PARALLEL_SERVERS_TARGET, + parallel_servers_target))) { + LOG_WARN("fail read tenant variable", K(ret), K(session.get_effective_tenant_id())); + } else { + params.unit_min_cpu_ = std::max(tenant->unit_min_cpu(), 0.0); + params.parallel_servers_target_ = std::max(parallel_servers_target, 0L); + } } if (OB_SUCC(ret)) { - ctx_.set_parallel_degree_limit(parallel_degree_limit); - ctx_.set_parallel_min_scan_time_threshold(parallel_min_scan_time_threshold); + params.parallel_min_scan_time_threshold_ = parallel_min_scan_time_threshold; + params.parallel_degree_limit_ = parallel_degree_limit; + ctx_.set_auto_dop_params(params); } return ret; } diff --git a/src/sql/optimizer/ob_optimizer_context.h b/src/sql/optimizer/ob_optimizer_context.h index 491e04cbbb..b524be2a45 100644 --- a/src/sql/optimizer/ob_optimizer_context.h +++ b/src/sql/optimizer/ob_optimizer_context.h @@ -84,6 +84,38 @@ struct TableLocRelInfo common::ObArray table_part_infos_; }; +struct AutoDOPParams { + AutoDOPParams() + : parallel_degree_limit_(0), + parallel_servers_target_(0), + unit_min_cpu_(0), + parallel_min_scan_time_threshold_(1000) + { } + + int64_t get_parallel_degree_limit(const int64_t server_cnt) const { + int64_t limit = 0; + if (0 < parallel_degree_limit_) { + limit = parallel_degree_limit_; + } else if (0 >= parallel_servers_target_ || 0 >= unit_min_cpu_ || 0 >= server_cnt) { + limit = std::max(parallel_servers_target_, server_cnt * unit_min_cpu_); + } else { + limit = std::min(parallel_servers_target_, server_cnt * unit_min_cpu_); + } + return std::max(limit, 1L); + } + bool is_valid() { return parallel_min_scan_time_threshold_ >= 10 + && (parallel_degree_limit_ > 0 || parallel_servers_target_ > 0 + || unit_min_cpu_ > 0); } + TO_STRING_KV(K_(parallel_degree_limit), + K_(parallel_servers_target), + K_(unit_min_cpu), + K_(parallel_min_scan_time_threshold)); + int64_t parallel_degree_limit_; + int64_t parallel_servers_target_; + int64_t unit_min_cpu_; + int64_t parallel_min_scan_time_threshold_; // auto dop threshold for table scan cost +}; + class ObOptimizerContext { @@ -119,8 +151,7 @@ ObOptimizerContext(ObSQLSessionInfo *session_info, px_parallel_rule_(PXParallelRule::USE_PX_DEFAULT), can_use_pdml_(false), max_parallel_(ObGlobalHint::UNSET_PARALLEL), - parallel_degree_limit_(ObGlobalHint::UNSET_PARALLEL), - parallel_min_scan_time_threshold_(-1), + auto_dop_params_(), is_online_ddl_(false), ddl_sample_column_count_(0), is_heap_table_ddl_(false), @@ -237,8 +268,8 @@ ObOptimizerContext(ObSQLSessionInfo *session_info, void set_serial_set_order(bool force_serial_set_order) { force_serial_set_order_ = force_serial_set_order; } inline int64_t get_parallel() const { return parallel_; } inline int64_t get_max_parallel() const { return max_parallel_; } - inline int64_t get_parallel_degree_limit() const { return parallel_degree_limit_; } - inline int64_t get_parallel_min_scan_time_threshold() const { return parallel_min_scan_time_threshold_; } + inline int64_t get_parallel_degree_limit(const int64_t server_cnt) const { return auto_dop_params_.get_parallel_degree_limit(server_cnt); } + inline int64_t get_parallel_min_scan_time_threshold() const { return auto_dop_params_.parallel_min_scan_time_threshold_; } inline bool force_disable_parallel() const { return px_parallel_rule_ >= PL_UDF_DAS_FORCE_SERIALIZE && px_parallel_rule_ < MAX_OPTION; } inline bool is_use_table_dop() const { return MANUAL_TABLE_DOP == px_parallel_rule_; } @@ -246,8 +277,8 @@ ObOptimizerContext(ObSQLSessionInfo *session_info, inline bool is_parallel_rule_valid() const { return MAX_OPTION != px_parallel_rule_; } void set_parallel(int64_t parallel) { parallel_ = parallel; } void set_max_parallel(int64_t max_parallel) { max_parallel_ = max_parallel_ < max_parallel ? max_parallel : max_parallel_; } - void set_parallel_degree_limit(int64_t parallel_degree_limit) { parallel_degree_limit_ = parallel_degree_limit; } - void set_parallel_min_scan_time_threshold(int64_t threshold) { parallel_min_scan_time_threshold_ = threshold; } + void set_auto_dop_params(const AutoDOPParams &auto_dop_params) { auto_dop_params_ = auto_dop_params; } + const AutoDOPParams &get_auto_dop_params() { return auto_dop_params_; } void set_can_use_pdml(bool u) { can_use_pdml_ = u; } inline ObFdItemFactory &get_fd_item_factory() { return fd_item_factory_; } void set_is_online_ddl(bool flag) { is_online_ddl_ = flag; } @@ -547,8 +578,7 @@ private: PXParallelRule px_parallel_rule_; bool can_use_pdml_; // can use pdml after check parallel int64_t max_parallel_; - int64_t parallel_degree_limit_; // parallel limit for auto dop - int64_t parallel_min_scan_time_threshold_; // auto dop threshold for table scan cost + AutoDOPParams auto_dop_params_; // parameters to calc dop for Auto DOP bool is_online_ddl_; int64_t ddl_sample_column_count_; bool is_heap_table_ddl_; // we need to treat heap table ddl seperately diff --git a/src/sql/resolver/dml/ob_hint.cpp b/src/sql/resolver/dml/ob_hint.cpp index cf68ef7b47..963bd0f38a 100644 --- a/src/sql/resolver/dml/ob_hint.cpp +++ b/src/sql/resolver/dml/ob_hint.cpp @@ -470,8 +470,6 @@ int ObGlobalHint::print_global_hint(PlanText &plan_text) const if (OB_SUCC(ret) && has_parallel_hint() && !ignore_parallel_for_dblink) { //PARALLEL if (has_parallel_degree()) { PRINT_GLOBAL_HINT_NUM("PARALLEL", parallel_); - } else if (plan_text.is_outline_data_) { - /* do not print parallel policy for outline data */ } else if (enable_auto_dop()) { PRINT_GLOBAL_HINT_STR("PARALLEL( AUTO )"); } else if (enable_manual_dop()) { @@ -502,7 +500,7 @@ int ObGlobalHint::print_global_hint(PlanText &plan_text) const } } // OPTIMIZER_FEATURES_ENABLE - if (OB_SUCC(ret) && (has_valid_opt_features_version() || plan_text.is_outline_data_)) { + if (OB_SUCC(ret) && (has_valid_opt_features_version())) { int64_t cur_pos = 0; const uint64_t version = has_valid_opt_features_version() ? opt_features_version_ : CURRENT_OUTLINE_ENABLE_VERSION;