MySQL 5.6.14 Source Code Document
|
#include "univ.i"
#include "btr0btr.h"
#include "btr0cur.h"
#include "dict0dict.h"
#include "dict0mem.h"
#include "dict0stats.h"
#include "data0type.h"
#include "db0err.h"
#include "page0page.h"
#include "pars0pars.h"
#include "pars0types.h"
#include "que0que.h"
#include "rem0cmp.h"
#include "row0sel.h"
#include "row0types.h"
#include "trx0trx.h"
#include "trx0roll.h"
#include "ut0rnd.h"
#include "ut0ut.h"
#include <vector>
#include "mysql_com.h"
Go to the source code of this file.
Macros | |
#define | TABLE_STATS_NAME "mysql/innodb_table_stats" |
#define | TABLE_STATS_NAME_PRINT "mysql.innodb_table_stats" |
#define | INDEX_STATS_NAME "mysql/innodb_index_stats" |
#define | INDEX_STATS_NAME_PRINT "mysql.innodb_index_stats" |
#define | DEBUG_PRINTF(fmt,...) /* noop */ |
#define | N_SAMPLE_PAGES(index) |
#define | N_DIFF_REQUIRED(index) (N_SAMPLE_PAGES(index) * 10) |
#define | INDEX_EQ(i1, i2) |
#define | PREPARE_PINFO_FOR_TABLE_SAVE(p, t, n) |
#define | PFX "n_diff_pfx" |
#define | PFX_LEN 10 |
Typedefs | |
typedef std::vector< ib_uint64_t > | boundaries_t |
Functions | |
UNIV_INLINE bool | dict_stats_should_ignore_index (const dict_index_t *index) |
UNIV_INTERN void | dict_stats_update_transient (dict_table_t *table) |
UNIV_INLINE | __attribute__ ((nonnull)) ulint *dict_stats_scan_page(const rec_t **out_rec |
UNIV_INTERN void | dict_stats_update_for_index (dict_index_t *index) |
UNIV_INTERN dberr_t | dict_stats_update (dict_table_t *table, dict_stats_upd_option_t stats_upd_option) |
UNIV_INTERN dberr_t | dict_stats_drop_index (const char *db_and_table, const char *iname, char *errstr, ulint errstr_sz) |
UNIV_INLINE dberr_t | dict_stats_delete_from_table_stats (const char *database_name, const char *table_name) |
UNIV_INLINE dberr_t | dict_stats_delete_from_index_stats (const char *database_name, const char *table_name) |
UNIV_INTERN dberr_t | dict_stats_drop_table (const char *db_and_table, char *errstr, ulint errstr_sz) |
UNIV_INLINE dberr_t | dict_stats_rename_in_table_stats (const char *old_dbname_utf8, const char *old_tablename_utf8, const char *new_dbname_utf8, const char *new_tablename_utf8) |
UNIV_INLINE dberr_t | dict_stats_rename_in_index_stats (const char *old_dbname_utf8, const char *old_tablename_utf8, const char *new_dbname_utf8, const char *new_tablename_utf8) |
UNIV_INTERN dberr_t | dict_stats_rename_table (const char *old_name, const char *new_name, char *errstr, size_t errstr_sz) |
Variables | |
UNIV_INLINE ulint * | offsets1 |
UNIV_INLINE ulint ulint * | offsets2 |
UNIV_INLINE ulint ulint dict_index_t * | index |
UNIV_INLINE ulint ulint dict_index_t const page_t * | page |
UNIV_INLINE ulint ulint dict_index_t const page_t ulint | n_prefix |
UNIV_INLINE ulint ulint dict_index_t const page_t ulint page_scan_method_t | scan_method |
enum | page_scan_method_t { COUNT_ALL_NON_BORING_AND_SKIP_DEL_MARKED, QUIT_ON_FIRST_NON_BORING } |
Code used for calculating and manipulating table statistics.
Created Jan 06, 2010 Vasil Dimov
Definition in file dict0stats.cc.
#define INDEX_EQ | ( | i1, | |
i2 | |||
) |
Definition at line 622 of file dict0stats.cc.
#define N_SAMPLE_PAGES | ( | index | ) |
Definition at line 129 of file dict0stats.cc.
#define PREPARE_PINFO_FOR_TABLE_SAVE | ( | p, | |
t, | |||
n | |||
) |
static __attribute__ | ( | (nonnull) | ) | const |
Scan a page, reading records from left to right and counting the number of distinct records on that page (looking only at the first n_prefix columns). If scan_method is QUIT_ON_FIRST_NON_BORING then the function will return as soon as it finds a record that does not match its neighbor to the right, which means that in the case of QUIT_ON_FIRST_NON_BORING the returned n_diff can either be 0 (empty page), 1 (the whole page has all keys equal) or 2 (the function found a non-boring record and returned).
Drop any indexes that we were not able to free previously due to open table handles.
Releases the mlocks and other objects stored in an mtr memo. They are released in the order opposite to which they were pushed to the memo.
< in/out: mini-transaction
Definition at line 108 of file mtr0mtr.cc.
UNIV_INLINE dberr_t dict_stats_delete_from_index_stats | ( | const char * | database_name, |
const char * | table_name | ||
) |
Executes DELETE FROM mysql.innodb_index_stats WHERE database_name = '...' AND table_name = '...'; Creates its own transaction and commits it.
database_name | in: database name, e.g. 'db' |
table_name | in: table name, e.g. 'table' |
Definition at line 3259 of file dict0stats.cc.
UNIV_INLINE dberr_t dict_stats_delete_from_table_stats | ( | const char * | database_name, |
const char * | table_name | ||
) |
Executes DELETE FROM mysql.innodb_table_stats WHERE database_name = '...' AND table_name = '...'; Creates its own transaction and commits it.
database_name | in: database name, e.g. 'db' |
table_name | in: table name, e.g. 'table' |
Definition at line 3221 of file dict0stats.cc.
UNIV_INTERN 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. 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 |
Definition at line 3134 of file dict0stats.cc.
UNIV_INTERN dberr_t dict_stats_drop_table | ( | const char * | db_and_table, |
char * | errstr, | ||
ulint | errstr_sz | ||
) |
Removes the statistics for a table and all of its indexes from the persistent statistics 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 |
Definition at line 3296 of file dict0stats.cc.
UNIV_INLINE dberr_t dict_stats_rename_in_index_stats | ( | const char * | old_dbname_utf8, |
const char * | old_tablename_utf8, | ||
const char * | new_dbname_utf8, | ||
const char * | new_tablename_utf8 | ||
) |
Executes UPDATE mysql.innodb_index_stats SET database_name = '...', table_name = '...' WHERE database_name = '...' AND table_name = '...'; Creates its own transaction and commits it.
old_dbname_utf8 | in: database name, e.g. 'olddb' |
old_tablename_utf8 | in: table name, e.g. 'oldtable' |
new_dbname_utf8 | in: database name, e.g. 'newdb' |
new_tablename_utf8 | in: table name, e.g. 'newtable' |
Definition at line 3421 of file dict0stats.cc.
UNIV_INLINE dberr_t dict_stats_rename_in_table_stats | ( | const char * | old_dbname_utf8, |
const char * | old_tablename_utf8, | ||
const char * | new_dbname_utf8, | ||
const char * | new_tablename_utf8 | ||
) |
Executes UPDATE mysql.innodb_table_stats SET database_name = '...', table_name = '...' WHERE database_name = '...' AND table_name = '...'; Creates its own transaction and commits it.
old_dbname_utf8 | in: database name, e.g. 'olddb' |
old_tablename_utf8 | in: table name, e.g. 'oldtable' |
new_dbname_utf8 | in: database name, e.g. 'newdb' |
new_tablename_utf8 | in: table name, e.g. 'newtable' |
Definition at line 3375 of file dict0stats.cc.
UNIV_INTERN 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.
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 |
Definition at line 3464 of file dict0stats.cc.
UNIV_INLINE bool dict_stats_should_ignore_index | ( | const dict_index_t * | index | ) |
Checks whether an index should be ignored in stats manipulations: stats fetch stats recalc stats save
index | in: index |
Definition at line 154 of file dict0stats.cc.
UNIV_INTERN dberr_t dict_stats_update | ( | dict_table_t * | table, |
dict_stats_upd_option_t | stats_upd_option | ||
) |
Calculates new estimates for table and index statistics. The statistics are used in query optimization.
table | in/out: table |
stats_upd_option | in: whether to (re) calc the stats or to fetch them from the persistent statistics storage |
Definition at line 2894 of file dict0stats.cc.
UNIV_INTERN void dict_stats_update_for_index | ( | dict_index_t * | index | ) |
Fetches or calculates new estimates for index statistics.
index | in/out: index |
Definition at line 2846 of file dict0stats.cc.
UNIV_INTERN void dict_stats_update_transient | ( | dict_table_t * | table | ) |
Calculates new estimates for table and index statistics. This function is relatively quick and is used to calculate transient statistics that are not saved on disk. This was the only way to calculate statistics before the Persistent Statistics feature was introduced.
table | in/out: table |
Definition at line 834 of file dict0stats.cc.
UNIV_INLINE ulint ulint dict_index_t* index |
in: index of the page
Definition at line 1266 of file dict0stats.cc.
UNIV_INLINE ulint ulint dict_index_t const page_t ulint n_prefix |
in: look at the first n_prefix columns
Definition at line 1266 of file dict0stats.cc.
UNIV_INLINE ulint* offsets1 |
< out: record, or NULL out: rec_get_offsets() working space (must be big enough)
Definition at line 1266 of file dict0stats.cc.
UNIV_INLINE ulint ulint* offsets2 |
out: rec_get_offsets() working space (must be big enough)
Definition at line 1266 of file dict0stats.cc.
UNIV_INLINE ulint ulint dict_index_t const page_t* page |
in: the page to scan
Definition at line 1266 of file dict0stats.cc.
UNIV_INLINE ulint ulint dict_index_t const page_t ulint page_scan_method_t scan_method |
in: scan to the end of the page or not
Definition at line 1266 of file dict0stats.cc.