diff --git a/storage/tianchi/ha_tse.cc b/storage/tianchi/ha_tse.cc index 6819c621ee1c417ca48cf3ba4c751da7acd48abb..07e70b2ed56883553a5f388a6b4d9a86b790807d 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 f1d1239007492a5b8edfbce9f7a970d632767745..ac2852a3903039b6baa6430f1c7a06f77190efc2 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;//列在索引中的偏移量