From 97dca1dc6177d39fef054213750f05d46be1433d Mon Sep 17 00:00:00 2001 From: Jiachen1018 Date: Mon, 15 Apr 2024 15:36:33 +0800 Subject: [PATCH] fix no stats --- storage/tianchi/ha_tse.cc | 2 +- storage/tianchi/tse_cbo.cc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/tianchi/ha_tse.cc b/storage/tianchi/ha_tse.cc index 6819c62..07e70b2 100644 --- a/storage/tianchi/ha_tse.cc +++ b/storage/tianchi/ha_tse.cc @@ -3911,7 +3911,7 @@ ha_rows ha_tse::records_in_range(uint inx, key_range *min_key, if (m_share) { if (!m_share->cbo_stats->is_updated) { tse_log_debug("table %s has not been analyzed", table->alias); - density = DEFAULT_RANGE_DENSITY; + return 1; } density = calc_density_one_table(inx, &key, m_share->cbo_stats->tse_cbo_stats_table, *table); /* diff --git a/storage/tianchi/tse_cbo.cc b/storage/tianchi/tse_cbo.cc index f1d1239..ac2852a 100644 --- a/storage/tianchi/tse_cbo.cc +++ b/storage/tianchi/tse_cbo.cc @@ -403,6 +403,9 @@ double calc_density_by_cond(tse_cbo_stats_table_t cbo_stats, KEY_PART_INFO cur_i double calc_density_one_table(uint16_t idx_id, tse_range_key *key, tse_cbo_stats_table_t cbo_stats, const TABLE &table) { + if (cbo_stats.estimate_rows == 0) { // no stats or empty table + return 0; + } double density = 1.0; uint32 col_id; uint32_t key_offset = 0;//列在索引中的偏移量 -- Gitee