MySQL 8.0.40
Source Code Documentation
anonymous_namespace{table_stats.cc} Namespace Reference

Classes

class  Update_I_S_statistics_ctx
 A RAII to used to allow updates in the DD tables mysql.index_stats and mysql.index_stats. More...
 

Functions

bool can_persist_I_S_dynamic_statistics (THD *thd, const char *schema_name, const char *partition_name)
 Update the data in the mysql.index_stats table if,. More...
 
bool is_persistent_statistics_expired (THD *thd, const ulonglong &cached_timestamp)
 
template<typename T >
bool store_statistics_record (THD *thd, T *object)
 Store the statistics into DD tables mysql.table_stats and mysql.index_stats. More...
 
template bool store_statistics_record (THD *thd, dd::Table_stat *)
 
template bool store_statistics_record (THD *thd, dd::Index_stat *)
 
void setup_table_stats_record (THD *thd, dd::Table_stat *obj, dd::String_type schema_name, dd::String_type table_name, const ha_statistics &stats, ulonglong checksum, bool has_checksum, bool has_autoinc)
 
void setup_index_stats_record (THD *thd, dd::Index_stat *obj, dd::String_type schema_name, dd::String_type table_name, dd::String_type index_name, dd::String_type column_name, ulonglong records)
 
static bool persist_i_s_table_stats (THD *thd, const ha_statistics &stats, const String &schema_name_ptr, const String &table_name_ptr, const ulonglong &checksum)
 Get dynamic table statistics of a table and store them into mysql.table_stats. More...
 
static bool persist_i_s_index_stats (THD *thd, const String &schema_name_ptr, const String &table_name_ptr, const String &index_name_ptr, const String &column_name_ptr, ulonglong records)
 Get dynamic index statistics of a table and store them into mysql.index_stats. More...
 
static bool report_error_except_ignore_dup (THD *thd, const char *object_type)
 

Function Documentation

◆ can_persist_I_S_dynamic_statistics()

bool anonymous_namespace{table_stats.cc}::can_persist_I_S_dynamic_statistics ( THD thd,
const char *  schema_name,
const char *  partition_name 
)
inline

Update the data in the mysql.index_stats table if,.

  • information_schema_stats_expiry is not ZERO OR
  • None of the innodb_read_only, read_only, super_read_only or transactional_read_only is ON, OR
  • Not in multi transaction mode. i.e., not in START TRANSACTION or AUTOCOMMIT=0.
  • Table is not a partitioned table.
  • Table is not a performance schema table.
Parameters
thd- Thread ID
schema_name- The schema name.
partition_name- The partition name
Returns
true if we can update the statistics, otherwise false.

◆ is_persistent_statistics_expired()

bool anonymous_namespace{table_stats.cc}::is_persistent_statistics_expired ( THD thd,
const ulonglong cached_timestamp 
)
inline

◆ persist_i_s_index_stats()

static bool anonymous_namespace{table_stats.cc}::persist_i_s_index_stats ( THD thd,
const String schema_name_ptr,
const String table_name_ptr,
const String index_name_ptr,
const String column_name_ptr,
ulonglong  records 
)
static

Get dynamic index statistics of a table and store them into mysql.index_stats.

Parameters
thdThread.
schema_name_ptrSchema name
table_name_ptrTable name
index_name_ptrIndex name
column_name_ptrColumn name
recordsValue for cardinality
Returns
false on success, otherwise true.

◆ persist_i_s_table_stats()

static bool anonymous_namespace{table_stats.cc}::persist_i_s_table_stats ( THD thd,
const ha_statistics stats,
const String schema_name_ptr,
const String table_name_ptr,
const ulonglong checksum 
)
static

Get dynamic table statistics of a table and store them into mysql.table_stats.

Parameters
thdThread.
statsStatistics object
schema_name_ptrSchema name
table_name_ptrTable name
checksumChecksum value
Returns
false on success, otherwise true.

◆ report_error_except_ignore_dup()

static bool anonymous_namespace{table_stats.cc}::report_error_except_ignore_dup ( THD thd,
const char *  object_type 
)
static

◆ setup_index_stats_record()

void anonymous_namespace{table_stats.cc}::setup_index_stats_record ( THD thd,
dd::Index_stat obj,
dd::String_type  schema_name,
dd::String_type  table_name,
dd::String_type  index_name,
dd::String_type  column_name,
ulonglong  records 
)
inline

◆ setup_table_stats_record()

void anonymous_namespace{table_stats.cc}::setup_table_stats_record ( THD thd,
dd::Table_stat obj,
dd::String_type  schema_name,
dd::String_type  table_name,
const ha_statistics stats,
ulonglong  checksum,
bool  has_checksum,
bool  has_autoinc 
)
inline

◆ store_statistics_record() [1/3]

template bool anonymous_namespace{table_stats.cc}::store_statistics_record ( THD thd,
dd::Index_stat  
)

◆ store_statistics_record() [2/3]

template bool anonymous_namespace{table_stats.cc}::store_statistics_record ( THD thd,
dd::Table_stat  
)

◆ store_statistics_record() [3/3]

template<typename T >
bool anonymous_namespace{table_stats.cc}::store_statistics_record ( THD thd,
T *  object 
)

Store the statistics into DD tables mysql.table_stats and mysql.index_stats.

It is ok to ignore ER_DUP_ENTRY, because there is possibility that another thread would have updated statistics in high concurrent environment. See Bug#29948755 for more information.