[FEAT MERGE] [CP] Improve the rowcount estimation
Co-authored-by: akaError <lzg020616@163.com>
This commit is contained in:
@ -636,6 +636,7 @@ int ObOptStatManager::get_table_stat(const uint64_t tenant_id,
|
||||
opt_stat.get_macro_block_num() * scale_ratio,
|
||||
opt_stat.get_micro_block_num() * scale_ratio);
|
||||
stat.set_last_analyzed(opt_stat.get_last_analyzed());
|
||||
stat.set_stat_locked(opt_stat.is_locked());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1953,7 +1953,8 @@ int ObOptStatSqlService::fetch_table_rowcnt(const uint64_t tenant_id,
|
||||
ObSchemaUtils::get_real_table_mappings_tid(table_id) : table_id;
|
||||
if (OB_FAIL(gen_tablet_list_str(all_tablet_ids, all_ls_ids, tablet_list_str, tablet_ls_list_str))) {
|
||||
LOG_WARN("failed to gen tablet list str", K(ret));
|
||||
} else if (OB_FAIL(raw_sql.append_fmt("select /*+opt_param('enable_in_range_optimization','true')*/ tablet_id, max(row_count) from "\
|
||||
} else if (OB_FAIL(raw_sql.append_fmt("select /*+opt_param('enable_in_range_optimization','true') opt_param('use_default_opt_stat','true')*/"\
|
||||
"tablet_id, max(row_count) from "\
|
||||
"(select cast(tablet_id as unsigned) as tablet_id, cast(inserts - deletes as signed) as row_count "\
|
||||
"from %s where tenant_id = %lu and table_id = %lu and tablet_id in %s union all "\
|
||||
"select cast(tablet_id as unsigned) as tablet_id, cast(row_count as signed) as row_count from %s, "\
|
||||
|
||||
@ -302,7 +302,8 @@ public:
|
||||
ObGlobalTableStat()
|
||||
: row_count_(0), row_size_(0), data_size_(0),
|
||||
macro_block_count_(0), micro_block_count_(0), part_cnt_(0), last_analyzed_(0),
|
||||
cg_macro_cnt_arr_(), cg_micro_cnt_arr_()
|
||||
cg_macro_cnt_arr_(), cg_micro_cnt_arr_(),
|
||||
stat_locked_(false)
|
||||
{}
|
||||
|
||||
void add(int64_t rc, int64_t rs, int64_t ds, int64_t mac, int64_t mic);
|
||||
@ -318,6 +319,8 @@ public:
|
||||
const ObIArray<int64_t> &get_cg_macro_arr() const { return cg_macro_cnt_arr_; }
|
||||
const ObIArray<int64_t> &get_cg_micro_arr() const { return cg_micro_cnt_arr_; }
|
||||
void set_last_analyzed(int64_t last_analyzed) { last_analyzed_ = last_analyzed; }
|
||||
void set_stat_locked(bool locked) { stat_locked_ = locked; }
|
||||
bool get_stat_locked() const { return stat_locked_; }
|
||||
|
||||
|
||||
TO_STRING_KV(K(row_count_),
|
||||
@ -328,7 +331,8 @@ public:
|
||||
K(part_cnt_),
|
||||
K(last_analyzed_),
|
||||
K(cg_macro_cnt_arr_),
|
||||
K(cg_micro_cnt_arr_));
|
||||
K(cg_micro_cnt_arr_),
|
||||
K(stat_locked_));
|
||||
|
||||
private:
|
||||
int64_t row_count_;
|
||||
@ -340,6 +344,7 @@ private:
|
||||
int64_t last_analyzed_;
|
||||
ObArray<int64_t> cg_macro_cnt_arr_;
|
||||
ObArray<int64_t> cg_micro_cnt_arr_;
|
||||
bool stat_locked_;
|
||||
};
|
||||
|
||||
class ObGlobalNullEval
|
||||
|
||||
Reference in New Issue
Block a user