adjust auto dop

This commit is contained in:
obdev
2023-09-08 11:53:52 +08:00
committed by ob-robot
parent 73ae6ba395
commit 0ca39e9932
7 changed files with 144 additions and 74 deletions

View File

@ -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<ObDelUpdLogPlan*>(&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);

View File

@ -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,