From 61c367fbceec35f63ddb24e42b13605c167bbdec Mon Sep 17 00:00:00 2001 From: wangt1xiuyi <13547954130@163.com> Date: Sat, 10 Feb 2024 00:51:46 +0000 Subject: [PATCH] disable gather hidden table stats and add estimate block cnt trace point for analyze --- src/share/stat/ob_dbms_stats_executor.cpp | 3 ++- src/share/stat/ob_dbms_stats_preferences.cpp | 4 ++-- src/share/stat/ob_dbms_stats_utils.cpp | 2 +- src/share/stat/ob_index_stats_estimator.cpp | 3 ++- src/sql/resolver/ddl/ob_analyze_stmt.cpp | 4 ++++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/share/stat/ob_dbms_stats_executor.cpp b/src/share/stat/ob_dbms_stats_executor.cpp index d3363fd42f..79acf7dbbb 100644 --- a/src/share/stat/ob_dbms_stats_executor.cpp +++ b/src/share/stat/ob_dbms_stats_executor.cpp @@ -1200,7 +1200,8 @@ int ObDbmsStatsExecutor::gather_index_stats(ObExecContext &ctx, ObModIds::OB_HASH_BUCKET_TABLE_STATISTICS, param.tenant_id_))) { LOG_WARN("failed to create hash map", K(ret)); - } else if (OB_FAIL(ObBasicStatsEstimator::estimate_block_count(ctx, param, + } else if (param.need_estimate_block_ && + OB_FAIL(ObBasicStatsEstimator::estimate_block_count(ctx, param, partition_id_block_map))) { LOG_WARN("failed to estimate block count", K(ret)); } else if (OB_FAIL(ObDbmsStatsUtils::prepare_gather_stat_param(param, INVALID_LEVEL, &partition_id_block_map, diff --git a/src/share/stat/ob_dbms_stats_preferences.cpp b/src/share/stat/ob_dbms_stats_preferences.cpp index 166e10858d..cea3672617 100644 --- a/src/share/stat/ob_dbms_stats_preferences.cpp +++ b/src/share/stat/ob_dbms_stats_preferences.cpp @@ -328,7 +328,7 @@ int ObDbmsStatsPreferences::get_sys_default_stat_options(ObExecContext &ctx, } else if (OB_FAIL(get_no_acquired_prefs(stat_prefs, no_acquired_prefs))) { LOG_WARN("failed to get no acquired prefs", K(ret)); } else if (no_acquired_prefs.empty()) {//have got all expected sys prefs from user prefs sys table - LOG_TRACE("succeed to get sys default stat options", K(stat_prefs), K(param)); + LOG_TRACE("succeed to get sys default stat options", K(param)); } else {//try get sys prefs from global prefs sys table raw_sql.reset(); sname_list.reset(); @@ -631,7 +631,7 @@ int ObDbmsStatsPreferences::do_get_sys_perfs(ObExecContext &ctx, LOG_WARN("failed to get result", K(ret)); } else { ret = OB_SUCCESS; - LOG_TRACE("Succeed to do get sys perfs", K(raw_sql), K(need_acquired_prefs)); + LOG_TRACE("Succeed to do get sys perfs", K(raw_sql), K(param)); } } int tmp_ret = OB_SUCCESS; diff --git a/src/share/stat/ob_dbms_stats_utils.cpp b/src/share/stat/ob_dbms_stats_utils.cpp index 57954b8971..e71d8b642c 100644 --- a/src/share/stat/ob_dbms_stats_utils.cpp +++ b/src/share/stat/ob_dbms_stats_utils.cpp @@ -178,7 +178,7 @@ int ObDbmsStatsUtils::check_is_stat_table(share::schema::ObSchemaGetterGuard &sc is_valid = !is_no_stat_virtual_table(table_id); } else if (OB_FAIL(schema_guard.get_table_schema(tenant_id, table_id, table_schema))) { LOG_WARN("failed to get table schema", K(ret), K(tenant_id), K(table_id)); - } else if (OB_ISNULL(table_schema)) { + } else if (OB_ISNULL(table_schema) || OB_UNLIKELY(!table_schema->is_normal_schema())) { //do nothing } else {//check user table is_valid = table_schema->is_user_table() || table_schema->is_external_table(); diff --git a/src/share/stat/ob_index_stats_estimator.cpp b/src/share/stat/ob_index_stats_estimator.cpp index 8c4866379b..3b9b772161 100644 --- a/src/share/stat/ob_index_stats_estimator.cpp +++ b/src/share/stat/ob_index_stats_estimator.cpp @@ -259,7 +259,8 @@ int ObIndexStatsEstimator::fast_gather_index_stats(ObExecContext &ctx, ObModIds::OB_HASH_BUCKET_TABLE_STATISTICS, index_param.tenant_id_))) { LOG_WARN("failed to create hash map", K(ret)); - } else if (OB_FAIL(ObBasicStatsEstimator::estimate_block_count(ctx, index_param, partition_id_block_map))) { + } else if (index_param.need_estimate_block_ && + OB_FAIL(ObBasicStatsEstimator::estimate_block_count(ctx, index_param, partition_id_block_map))) { LOG_WARN("failed to estimate block count", K(ret)); } else { bool is_continued = true; diff --git a/src/sql/resolver/ddl/ob_analyze_stmt.cpp b/src/sql/resolver/ddl/ob_analyze_stmt.cpp index d5a34be9cf..2432d7309e 100644 --- a/src/sql/resolver/ddl/ob_analyze_stmt.cpp +++ b/src/sql/resolver/ddl/ob_analyze_stmt.cpp @@ -151,6 +151,10 @@ int ObAnalyzeTableInfo::fill_table_stat_param(ObExecContext &ctx, common::ObTabl if (param.part_stat_param_.need_modify_ && param.subpart_stat_param_.need_modify_) { param.part_stat_param_.can_use_approx_ = true; } + bool no_estimate_block = (OB_E(EventTable::EN_LEADER_STORAGE_ESTIMATION) OB_SUCCESS) != OB_SUCCESS; + if (no_estimate_block) { + param.need_estimate_block_ = false; + } } LOG_TRACE("link bug", K(param));