[FEAT MERGE][CP]optimizer stats enhancement
This commit is contained in:
@ -61,6 +61,12 @@ struct ObOptKeyInfo
|
||||
struct ObOptKeyColumnStat
|
||||
{
|
||||
ObOptKeyColumnStat() : key_(NULL), stat_(NULL), only_histogram_stat_(false) {}
|
||||
ObOptKeyColumnStat(const ObOptColumnStat::Key *key,
|
||||
ObOptColumnStat *stat) :
|
||||
key_(key),
|
||||
stat_(stat),
|
||||
only_histogram_stat_(false)
|
||||
{}
|
||||
const ObOptColumnStat::Key *key_;
|
||||
ObOptColumnStat *stat_;
|
||||
bool only_histogram_stat_;
|
||||
@ -68,6 +74,15 @@ struct ObOptKeyColumnStat
|
||||
KPC_(stat),
|
||||
K(only_histogram_stat_));
|
||||
};
|
||||
|
||||
enum ObOptStatCompressType
|
||||
{
|
||||
ZLIB_COMPRESS = 0,
|
||||
ZSTD_1_3_8_COMPRESS = 1,
|
||||
MAX_COMPRESS = 2
|
||||
};
|
||||
|
||||
static const char *bitmap_compress_lib_name[ObOptStatCompressType::MAX_COMPRESS] = {"zlib_1.0", "zstd_1.3.8"};
|
||||
/**
|
||||
* SQL Service for fetching/updating table level statistics and column level statistics
|
||||
*/
|
||||
@ -83,6 +98,12 @@ public:
|
||||
const ObOptTableStat::Key &key,
|
||||
ObIArray<ObOptTableStat> &all_part_stats);
|
||||
|
||||
int batch_fetch_table_stats(sqlclient::ObISQLConnection *conn,
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t table_id,
|
||||
const ObIArray<int64_t> &part_ids,
|
||||
ObIArray<ObOptTableStat*> &all_part_stats);
|
||||
|
||||
int fill_table_stat(sqlclient::ObMySQLResult &result, ObOptTableStat &stat);
|
||||
|
||||
int fill_column_stat(ObIAllocator &allocator,
|
||||
@ -93,46 +114,50 @@ public:
|
||||
int fetch_column_stat(const uint64_t tenant_id,
|
||||
ObIAllocator &allocator,
|
||||
ObIArray<ObOptKeyColumnStat> &key_col_stats,
|
||||
bool is_accross_tenant_query = false);
|
||||
bool is_accross_tenant_query = false,
|
||||
sqlclient::ObISQLConnection *conn = NULL);
|
||||
|
||||
int update_table_stat(const uint64_t tenant_id,
|
||||
sqlclient::ObISQLConnection *conn,
|
||||
const ObOptTableStat *tab_stat,
|
||||
const bool is_index_stat);
|
||||
int update_table_stat(const uint64_t tenant_id,
|
||||
ObMySQLTransaction &trans,
|
||||
sqlclient::ObISQLConnection *conn,
|
||||
const common::ObIArray<ObOptTableStat*> &table_stats,
|
||||
const int64_t current_time,
|
||||
const bool is_index_stat,
|
||||
const bool is_history_stat = false);
|
||||
const bool is_index_stat);
|
||||
int update_column_stat(share::schema::ObSchemaGetterGuard *schema_guard,
|
||||
const uint64_t exec_tenant_id,
|
||||
ObIAllocator &allocator,
|
||||
ObMySQLTransaction &trans,
|
||||
sqlclient::ObISQLConnection *conn,
|
||||
const common::ObIArray<ObOptColumnStat*> &column_stats,
|
||||
const int64_t current_time,
|
||||
bool only_update_col_stat = false,
|
||||
bool is_history_stat = false,
|
||||
const ObObjPrintParams &print_params = ObObjPrintParams());
|
||||
|
||||
int delete_table_stat(const uint64_t exec_tenant_id,
|
||||
const uint64_t table_id,
|
||||
const ObIArray<int64_t> &part_ids,
|
||||
const bool cascade_column,
|
||||
int64_t degree,
|
||||
int64_t &affected_rows);
|
||||
|
||||
int delete_column_stat(const uint64_t exec_tenant_id,
|
||||
const uint64_t table_id,
|
||||
const ObIArray<uint64_t> &column_ids,
|
||||
const ObIArray<int64_t> &partition_ids,
|
||||
const bool only_histogram /*=false*/);
|
||||
const bool only_histogram /*=false*/,
|
||||
const int64_t degree);
|
||||
|
||||
static int get_decompressed_llc_bitmap(ObIAllocator &allocator,
|
||||
const char *bitmap_compress_name,
|
||||
const char *comp_buf,
|
||||
int64_t comp_size,
|
||||
char *&bitmap_buf,
|
||||
int64_t &bitmap_size);
|
||||
|
||||
static int get_compressed_llc_bitmap(ObIAllocator &allocator,
|
||||
const char *bitmap_compress_name,
|
||||
const char *bitmap_buf,
|
||||
int64_t bitmap_size,
|
||||
char *&comp_buf,
|
||||
@ -185,10 +210,6 @@ private:
|
||||
const int64_t current_time,
|
||||
const bool is_index,
|
||||
ObSqlString &sql_string);
|
||||
int get_table_stat_history_sql(const uint64_t tenant_id,
|
||||
const ObOptTableStat &stat,
|
||||
const int64_t saving_time,
|
||||
ObSqlString &sql_string);
|
||||
int get_column_stat_sql(const uint64_t tenant_id,
|
||||
ObIAllocator &allocator,
|
||||
const ObOptColumnStat &stat,
|
||||
@ -197,14 +218,6 @@ private:
|
||||
ObObjMeta max_meta,
|
||||
ObSqlString &sql_string,
|
||||
const ObObjPrintParams &print_params);
|
||||
int get_column_stat_history_sql(const uint64_t tenant_id,
|
||||
ObIAllocator &allocator,
|
||||
const ObOptColumnStat &stat,
|
||||
const int64_t saving_time,
|
||||
ObObjMeta min_meta,
|
||||
ObObjMeta max_meta,
|
||||
ObSqlString &sql_string,
|
||||
const ObObjPrintParams &print_params);
|
||||
int get_histogram_stat_sql(const uint64_t tenant_id,
|
||||
const ObOptColumnStat &stat,
|
||||
common::ObIAllocator &allocator,
|
||||
@ -212,14 +225,6 @@ private:
|
||||
ObObjMeta endpoint_meta,
|
||||
ObSqlString &sql_string,
|
||||
const ObObjPrintParams &print_params);
|
||||
int get_histogram_stat_history_sql(const uint64_t tenant_id,
|
||||
const ObOptColumnStat &stat,
|
||||
ObIAllocator &allocator,
|
||||
const ObHistBucket &bucket,
|
||||
const int64_t saving_time,
|
||||
ObObjMeta endpoint_meta,
|
||||
ObSqlString &sql_string,
|
||||
const ObObjPrintParams &print_params);
|
||||
|
||||
int generate_in_list(const ObIArray<uint64_t> &list,
|
||||
ObSqlString &sql_string);
|
||||
@ -229,7 +234,6 @@ private:
|
||||
ObIAllocator &allocator,
|
||||
const ObIArray<ObOptColumnStat*> &column_stats,
|
||||
const int64_t current_time,
|
||||
bool is_history_stat,
|
||||
ObSqlString &column_stats_sql,
|
||||
const ObObjPrintParams &print_params);
|
||||
|
||||
@ -242,7 +246,6 @@ private:
|
||||
ObIAllocator &allocator,
|
||||
const ObIArray<ObOptColumnStat*> &column_stats,
|
||||
const int64_t current_time,
|
||||
bool is_history_stat,
|
||||
ObSqlString &insert_histogram_sql,
|
||||
bool &need_histogram,
|
||||
const ObObjPrintParams &print_params);
|
||||
@ -289,8 +292,6 @@ private:
|
||||
|
||||
int fill_system_stat(sqlclient::ObMySQLResult &result, ObOptSystemStat &stat);
|
||||
|
||||
static const char *bitmap_compress_lib_name;
|
||||
|
||||
bool inited_;
|
||||
ObMySQLProxy *mysql_proxy_;
|
||||
lib::ObMutex mutex_;
|
||||
|
||||
Reference in New Issue
Block a user