fix some master opt stats bug
This commit is contained in:
@ -352,6 +352,7 @@ int ObDbmsStats::gather_table_index_stats(ObExecContext &ctx,
|
||||
ObTableStatParam index_param;
|
||||
index_param.assign_common_property(data_param);
|
||||
const share::schema::ObTableSchema *index_schema = NULL;
|
||||
bool is_valid_index = true;
|
||||
if (OB_FAIL(parse_table_part_info(ctx, stat_table, index_param))) {
|
||||
LOG_WARN("failed to parse table part info", K(ret));
|
||||
} else if (OB_ISNULL(schema_guard) ||
|
||||
@ -361,10 +362,12 @@ int ObDbmsStats::gather_table_index_stats(ObExecContext &ctx,
|
||||
OB_ISNULL(index_schema)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to get index schema", K(ret), K(stat_table));
|
||||
} else if (!index_schema->is_normal_index() && !index_schema->is_unique_index()) {
|
||||
is_valid_index = false;
|
||||
} else if (index_schema->is_global_index_table()) {
|
||||
index_param.is_global_index_ = true;
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_SUCC(ret) && is_valid_index) {
|
||||
index_param.is_index_stat_ = true;
|
||||
index_param.global_stat_param_ = data_param.global_stat_param_;
|
||||
index_param.part_stat_param_.assign_without_part_type(data_param.part_stat_param_);
|
||||
@ -435,6 +438,8 @@ int ObDbmsStats::fast_gather_index_stats(ObExecContext &ctx,
|
||||
OB_ISNULL(index_schema)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to get index schema", K(ret), K(stat_table));
|
||||
} else if (!index_schema->is_normal_index() && !index_schema->is_unique_index()) {
|
||||
is_fast_gather = false;
|
||||
//glboal index can't reuse the partition data in fast gather index
|
||||
} else if (index_schema->is_global_index_table()) {
|
||||
index_param.is_global_index_ = true;
|
||||
@ -3274,6 +3279,11 @@ int ObDbmsStats::init_column_stat_params(ObIAllocator &allocator,
|
||||
if (ObColumnStatParam::is_valid_avglen_type(col->get_meta_type().get_type())) {
|
||||
col_param.set_need_avg_len();
|
||||
}
|
||||
//check can gather hist type, for longtext type, we disable gather hist
|
||||
if (ob_obj_type_class(col->get_meta_type().get_type()) == ColumnTypeClass::ObTextTC &&
|
||||
col->get_meta_type().get_type() != ObTinyTextType) {
|
||||
col_param.set_no_need_histogram();
|
||||
}
|
||||
}
|
||||
if (col->is_rowkey_column() && !table_schema.is_heap_table()) {
|
||||
col_param.set_is_index_column();
|
||||
@ -3738,6 +3748,10 @@ int ObDbmsStats::parse_index_table_info(ObExecContext &ctx,
|
||||
K(index_name));
|
||||
LOG_USER_ERROR(OB_TABLE_NOT_EXIST, to_cstring(data_table_param.db_name_),
|
||||
to_cstring(index_name));
|
||||
} else if (!index_schema->is_normal_index() && !index_schema->is_unique_index()) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("not support index tpye", K(ret), K(index_schema->get_index_type()));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "gather non-normal index stats");
|
||||
} else {
|
||||
param.tab_name_ = index_name;
|
||||
param.db_name_ = data_table_param.db_name_;
|
||||
|
||||
@ -230,6 +230,7 @@ int ObDbmsStatsUtils::check_is_sys_table(share::schema::ObSchemaGetterGuard &sch
|
||||
if (!is_sys_table(table_id) ||
|
||||
ObSysTableChecker::is_sys_table_index_tid(table_id) ||
|
||||
is_sys_lob_table(table_id) ||
|
||||
table_id == share::OB_ALL_CORE_TABLE_TID ||//circular dependency,
|
||||
table_id == share::OB_ALL_TABLE_STAT_TID ||
|
||||
table_id == share::OB_ALL_COLUMN_STAT_TID ||
|
||||
table_id == share::OB_ALL_HISTOGRAM_STAT_TID ||
|
||||
|
||||
@ -54,8 +54,7 @@ bool ObColumnStatParam::is_valid_opt_col_type(const ObObjType type)
|
||||
type_class == ColumnTypeClass::ObEnumSetTC ||
|
||||
type_class == ColumnTypeClass::ObIntervalTC ||
|
||||
type_class == ColumnTypeClass::ObDecimalIntTC ||
|
||||
(lib::is_mysql_mode() && (type == ObTinyTextType ||
|
||||
type == ObTextType))) {
|
||||
(lib::is_mysql_mode() && type_class == ColumnTypeClass::ObTextTC)) {
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
|
||||
@ -113,7 +113,8 @@ enum ColumnGatherFlag
|
||||
NO_NEED_STAT = 0,
|
||||
VALID_OPT_COL = 1,
|
||||
NEED_BASIC_STAT = 1 << 1,
|
||||
NEED_AVG_LEN = 1 << 2
|
||||
NEED_AVG_LEN = 1 << 2,
|
||||
NO_NEED_HISTOGRAM = 1 << 3
|
||||
};
|
||||
|
||||
enum ObGranularityType
|
||||
@ -374,9 +375,11 @@ struct ObColumnStatParam {
|
||||
inline void set_valid_opt_col() { gather_flag_ |= ColumnGatherFlag::VALID_OPT_COL; }
|
||||
inline void set_need_basic_stat() { gather_flag_ |= ColumnGatherFlag::NEED_BASIC_STAT; }
|
||||
inline void set_need_avg_len() { gather_flag_ |= ColumnGatherFlag::NEED_AVG_LEN; }
|
||||
inline void set_no_need_histogram() { gather_flag_ |= ColumnGatherFlag::NO_NEED_HISTOGRAM; }
|
||||
inline bool is_valid_opt_col() const { return gather_flag_ & ColumnGatherFlag::VALID_OPT_COL; }
|
||||
inline bool need_basic_stat() const { return gather_flag_ & ColumnGatherFlag::NEED_BASIC_STAT; }
|
||||
inline bool need_avg_len() const { return gather_flag_ & ColumnGatherFlag::NEED_AVG_LEN; }
|
||||
inline bool is_no_need_histogram() const { return gather_flag_ & ColumnGatherFlag::NO_NEED_HISTOGRAM; }
|
||||
|
||||
ObString column_name_;
|
||||
uint64_t column_id_;
|
||||
|
||||
@ -207,10 +207,10 @@ int ObStatLlcBitmap::decode(ObObj &obj)
|
||||
ObString llc_bitmap_buf;
|
||||
if (OB_ISNULL(col_stat_) ||
|
||||
OB_ISNULL(col_stat_->get_llc_bitmap()) ||
|
||||
OB_UNLIKELY(!obj.is_varchar())) {
|
||||
OB_UNLIKELY(!obj.is_varchar() && !obj.is_varbinary())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret), K(col_stat_), K(obj));
|
||||
} else if (OB_FAIL(obj.get_varchar(llc_bitmap_buf))) {
|
||||
} else if (OB_FAIL(obj.get_string(llc_bitmap_buf))) {
|
||||
LOG_WARN("failed to get varchar", K(ret));
|
||||
} else if (OB_UNLIKELY(llc_bitmap_buf.length() > col_stat_->get_llc_bitmap_size())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -227,6 +227,7 @@ bool ObStatTopKHist::is_needed() const
|
||||
{
|
||||
return NULL != col_param_ &&
|
||||
col_param_->need_basic_stat() &&
|
||||
!col_param_->is_no_need_histogram() &&
|
||||
col_param_->bucket_num_ > 1;
|
||||
}
|
||||
|
||||
|
||||
@ -750,7 +750,7 @@ int ObAccessService::put_rows(
|
||||
if (OB_SUCC(ret)) {
|
||||
int tmp_ret = audit_tablet_opt_dml_stat(dml_param,
|
||||
tablet_id,
|
||||
ObOptDmlStatType::TABLET_OPT_UPDATE_STAT,
|
||||
ObOptDmlStatType::TABLET_OPT_INSERT_STAT,
|
||||
affected_rows);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user