From 22cc03999404dfa0ced41c1eaf2947f622b0a814 Mon Sep 17 00:00:00 2001 From: hezuojiao Date: Thu, 17 Aug 2023 10:06:45 +0000 Subject: [PATCH] Fix rowsets hint invalidation and statistical information collection performance regression --- src/share/stat/ob_basic_stats_estimator.cpp | 2 +- src/share/stat/ob_hybrid_hist_estimator.cpp | 2 +- src/sql/code_generator/ob_code_generator.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/share/stat/ob_basic_stats_estimator.cpp b/src/share/stat/ob_basic_stats_estimator.cpp index f0e2b68275..967d6b031c 100644 --- a/src/share/stat/ob_basic_stats_estimator.cpp +++ b/src/share/stat/ob_basic_stats_estimator.cpp @@ -1172,7 +1172,7 @@ int ObBasicStatsEstimator::fill_hints(common::ObIAllocator &alloc, ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null", K(table_name)); } else { - const char *fmt_str = "NO_REWRITE USE_PLAN_CACHE(NONE) DBMS_STATS FULL(%.*s)"; + const char *fmt_str = "NO_REWRITE USE_PLAN_CACHE(NONE) DBMS_STATS FULL(%.*s) OPT_PARAM('ROWSETS_MAX_ROWS', 256)"; int64_t buf_len = table_name.length() + strlen(fmt_str); char *buf = NULL; if (OB_ISNULL(buf = static_cast(alloc.alloc(buf_len)))) { diff --git a/src/share/stat/ob_hybrid_hist_estimator.cpp b/src/share/stat/ob_hybrid_hist_estimator.cpp index cf2dda40f9..440d3e085e 100644 --- a/src/share/stat/ob_hybrid_hist_estimator.cpp +++ b/src/share/stat/ob_hybrid_hist_estimator.cpp @@ -317,7 +317,7 @@ int ObHybridHistEstimator::gen_query_sql(ObIAllocator &allocator, reset_select_items(); sample_hint_ = simple_hint; int64_t duration_time = -1; - ObString hint_str("NO_REWRITE USE_PLAN_CACHE(NONE) DBMS_STATS"); + ObString hint_str("NO_REWRITE USE_PLAN_CACHE(NONE) DBMS_STATS OPT_PARAM('ROWSETS_MAX_ROWS', 256)"); //add select items if (OB_ISNULL(dst_opt_stat.table_stat_)) { ret = OB_ERR_UNEXPECTED; diff --git a/src/sql/code_generator/ob_code_generator.cpp b/src/sql/code_generator/ob_code_generator.cpp index ebea346eff..984c3f5808 100644 --- a/src/sql/code_generator/ob_code_generator.cpp +++ b/src/sql/code_generator/ob_code_generator.cpp @@ -131,11 +131,12 @@ int ObCodeGenerator::detect_batch_size( 0, exec_ctx->get_min_cluster_version()); int64_t rowsets_max_rows = tenant_config->_rowsets_max_rows; - OZ(opt_params->get_integer_opt_param(ObOptParamHint::ROWSETS_MAX_ROWS, rowsets_max_rows)); OZ(expr_cg.detect_batch_size(flattened_exprs, batch_size, rowsets_max_rows, tenant_config->_rowsets_target_maxsize, scan_cardinality)); + // overwrite batch size if hint is specified + OZ(opt_params->get_integer_opt_param(ObOptParamHint::ROWSETS_MAX_ROWS, batch_size)); } // TODO qubin.qb: remove the tracelog when rowsets/batch_size is displayed // in plan