From 9cbbb91a7bef2f8f6b45492959c2debec41fbbab Mon Sep 17 00:00:00 2001 From: JinmaoLi Date: Wed, 15 May 2024 12:31:27 +0000 Subject: [PATCH] [CP] temporarily disable generating hash group by plans for keep aggrs --- src/sql/optimizer/ob_select_log_plan.cpp | 24 ++++++++++++++++++++++-- src/sql/optimizer/ob_select_log_plan.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/sql/optimizer/ob_select_log_plan.cpp b/src/sql/optimizer/ob_select_log_plan.cpp index ed6fa20b84..aeb2a8276e 100644 --- a/src/sql/optimizer/ob_select_log_plan.cpp +++ b/src/sql/optimizer/ob_select_log_plan.cpp @@ -389,6 +389,7 @@ int ObSelectLogPlan::get_valid_aggr_algo(const ObIArray &group_by_ex bool &normal_sort_valid) { int ret = OB_SUCCESS; + bool has_keep_aggr = false; if (ignore_hint) { use_hash_valid = true; use_merge_valid = true; @@ -403,10 +404,13 @@ int ObSelectLogPlan::get_valid_aggr_algo(const ObIArray &group_by_ex if (OB_ISNULL(get_stmt()) || OB_ISNULL(optimizer_context_.get_query_ctx())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null", K(get_stmt()), K(optimizer_context_.get_query_ctx()), K(ret)); + } else if (OB_FAIL(check_aggr_with_keep(get_stmt()->get_aggr_items(), has_keep_aggr))) { + LOG_WARN("failed to check aggr with keep", K(ret)); } else if (get_stmt()->has_rollup() || group_by_exprs.empty() - || get_stmt()->has_distinct_or_concat_agg()) { - //group_concat and distinct aggregation hold all input rows temporary, + || get_stmt()->has_distinct_or_concat_agg() + || has_keep_aggr) { + //keep_aggr、group_concat and distinct aggregation hold all input rows temporary, //too much memory consumption for hash aggregate. use_hash_valid = false; } @@ -7924,5 +7928,21 @@ int ObSelectLogPlan::candi_allocate_order_by_if_losted(ObIArray &orde return ret; } +int ObSelectLogPlan::check_aggr_with_keep(const ObIArray &aggr_items, + bool &has_keep_aggr) +{ + int ret = OB_SUCCESS; + has_keep_aggr = false; + for (int64_t i = 0; OB_SUCC(ret) && !has_keep_aggr && i < aggr_items.count(); ++i) { + if (OB_ISNULL(aggr_items.at(i))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("aggr item is null", K(ret)); + } else if (IS_KEEP_AGGR_FUN(aggr_items.at(i)->get_expr_type())) { + has_keep_aggr = true; + } + } + return ret; +} + }//sql }//oceanbase diff --git a/src/sql/optimizer/ob_select_log_plan.h b/src/sql/optimizer/ob_select_log_plan.h index 34627359bc..eb000756d0 100644 --- a/src/sql/optimizer/ob_select_log_plan.h +++ b/src/sql/optimizer/ob_select_log_plan.h @@ -930,6 +930,7 @@ int generate_window_functions_plan(WinFuncOpHelper &win_func_helper, int contain_enum_set_rowkeys(const ObLogTableScan &table_scan, bool &contain); int candi_allocate_order_by_if_losted(ObIArray &order_items); + int check_aggr_with_keep(const ObIArray& aggr_items, bool &has_keep_aggr); DISALLOW_COPY_AND_ASSIGN(ObSelectLogPlan); };