MySQL 9.1.0
Source Code Documentation
|
Code used for calculating and manipulating table statistics. More...
#include "univ.i"
#include "dict0types.h"
#include "mem0mem.h"
#include "trx0types.h"
#include "dict0stats.ic"
Go to the source code of this file.
Classes | |
class | TableStatsRecord |
Represent the record of innodb_table_stats table. More... | |
Enumerations | |
enum | dict_stats_upd_option_t { DICT_STATS_RECALC_PERSISTENT , DICT_STATS_RECALC_TRANSIENT , DICT_STATS_EMPTY_TABLE , DICT_STATS_FETCH_ONLY_IF_NOT_IN_MEMORY } |
Functions | |
static void | dict_stats_set_persistent (dict_table_t *table, bool ps_on, bool ps_off) |
Set the persistent statistics flag for a given table. More... | |
static bool | dict_stats_is_persistent_enabled (const dict_table_t *table) |
Check whether persistent statistics is enabled for a given table. More... | |
static void | dict_stats_auto_recalc_set (dict_table_t *table, bool auto_recalc_on, bool auto_recalc_off) |
Set the auto recalc flag for a given table (only honored for a persistent stats enabled table). More... | |
static bool | dict_stats_auto_recalc_is_enabled (const dict_table_t *table) |
Check whether auto recalc is enabled for a given table. More... | |
static void | dict_stats_init (dict_table_t *table) |
Initialize table's stats for the first time when opening a table. More... | |
static void | dict_stats_deinit (dict_table_t *table) |
Deinitialize table's stats after the last close of the table. More... | |
dberr_t | dict_stats_update (dict_table_t *table, dict_stats_upd_option_t stats_upd_option, trx_t *trx=nullptr) |
Calculates new estimates for table and index statistics. More... | |
dberr_t | dict_stats_drop_index (const char *tname, const char *iname, char *errstr, ulint errstr_sz) |
Removes the information for a particular index's stats from the persistent storage if it exists and if there is data stored for this index. More... | |
dberr_t | dict_stats_drop_table (const char *table_name, char *errstr, ulint errstr_sz) |
Removes the statistics for a table and all of its indexes from the persistent storage if it exists and if there is data stored for the table. More... | |
void | dict_stats_update_for_index (dict_index_t *index) |
Fetches or calculates new estimates for index statistics. More... | |
dberr_t | dict_stats_rename_table (const char *old_name, const char *new_name, char *errstr, size_t errstr_sz) |
Renames a table in InnoDB persistent stats storage. More... | |
dberr_t | dict_stats_rename_index (const dict_table_t *table, const char *old_index_name, const char *new_index_name) |
Renames an index in InnoDB persistent stats storage. More... | |
Code used for calculating and manipulating table statistics.
Created Jan 06, 2010 Vasil Dimov
|
inlinestatic |
Check whether auto recalc is enabled for a given table.
|
inlinestatic |
Set the auto recalc flag for a given table (only honored for a persistent stats enabled table).
The flag is set only in the in-memory table object and is not saved in InnoDB files. It will be read from the .frm file upon first open from MySQL after a server restart.
[in,out] | table | table |
[in] | auto_recalc_on | explicitly enabled |
[in] | auto_recalc_off | explicitly disabled |
|
inlinestatic |
Deinitialize table's stats after the last close of the table.
This is used to detect "FLUSH TABLE" and refresh the stats upon next open. in/out: table
dberr_t dict_stats_drop_index | ( | const char * | db_and_table, |
const char * | iname, | ||
char * | errstr, | ||
ulint | errstr_sz | ||
) |
Removes the information for a particular index's stats from the persistent storage if it exists and if there is data stored for this index.
This function creates its own trx and commits it.
This function creates its own trx and commits it. A note from Marko why we cannot edit user and sys_* tables in one trx: marko: The problem is that ibuf merges should be disabled while we are rolling back dict transactions. marko: If ibuf merges are not disabled, we need to scan the *.ibd files. But we shouldn't open *.ibd files before we have rolled back dict transactions and opened the SYS_* records for the *.ibd files.
db_and_table | in: db and table, e.g. 'db/table' |
iname | in: index name |
errstr | out: error message if != DB_SUCCESS is returned |
errstr_sz | in: size of the errstr buffer |
Removes the statistics for a table and all of its indexes from the persistent storage if it exists and if there is data stored for the table.
This function creates its own transaction and commits it.
Removes the statistics for a table and all of its indexes from the persistent storage if it exists and if there is data stored for the table.
This function creates its own transaction and commits it.
db_and_table | in: db and table, e.g. 'db/table' |
errstr | out: error message if != DB_SUCCESS is returned |
errstr_sz | in: size of errstr buffer |
|
inlinestatic |
Initialize table's stats for the first time when opening a table.
in/out: table
|
inlinestatic |
Check whether persistent statistics is enabled for a given table.
dberr_t dict_stats_rename_index | ( | const dict_table_t * | table, |
const char * | old_index_name, | ||
const char * | new_index_name | ||
) |
Renames an index in InnoDB persistent stats storage.
This function creates its own transaction and commits it.
This function creates its own transaction and commits it.
table | in: table whose index is renamed |
old_index_name | in: old index name |
new_index_name | in: new index name |
dberr_t dict_stats_rename_table | ( | const char * | old_name, |
const char * | new_name, | ||
char * | errstr, | ||
size_t | errstr_sz | ||
) |
Renames a table in InnoDB persistent stats storage.
This function creates its own transaction and commits it.
This function creates its own transaction and commits it.
old_name | in: old name, e.g. 'db/table' |
new_name | in: new name, e.g. 'db/table' |
errstr | out: error string if != DB_SUCCESS is returned |
errstr_sz | in: errstr size |
|
inlinestatic |
Set the persistent statistics flag for a given table.
This is set only in the in-memory table object and is not saved on disk. It will be read from the .frm file upon first open from MySQL after a server restart.
[in,out] | table | table |
[in] | ps_on | persistent stats explicitly enabled |
[in] | ps_off | persistent stats explicitly disabled |
dberr_t dict_stats_update | ( | dict_table_t * | table, |
dict_stats_upd_option_t | stats_upd_option, | ||
trx_t * | trx = nullptr |
||
) |
Calculates new estimates for table and index statistics.
The statistics are used in query optimization.
[in] | table | table for which statistics are to be updated. |
[in] | stats_upd_option | statistics update option (persistent, etc). |
[in] | trx | statistics update will be done as part of this transaction. if null, a new transaction will be internally created. |
void dict_stats_update_for_index | ( | dict_index_t * | index | ) |
Fetches or calculates new estimates for index statistics.
in/out: index
index | in/out: index |