MySQL 9.1.0
Source Code Documentation
|
Code used for background table and index stats gathering. More...
#include "sql_thd_internal_api.h"
#include <stddef.h>
#include <sys/types.h>
#include <vector>
#include "dict0dd.h"
#include "dict0dict.h"
#include "dict0stats.h"
#include "dict0stats_bg.h"
#include "os0thread-create.h"
#include "row0mysql.h"
#include "sql/histograms/histogram.h"
#include "srv0start.h"
#include "ut0new.h"
Typedefs | |
typedef ut::allocator< table_id_t > | recalc_pool_allocator_t |
Allocator type, used by std::vector. More... | |
typedef std::vector< table_id_t, recalc_pool_allocator_t > | recalc_pool_t |
The multitude of tables whose stats are to be automatically recalculated - an STL vector. More... | |
typedef recalc_pool_t::iterator | recalc_pool_iterator_t |
Iterator type for iterating over the elements of objects of type recalc_pool_t. More... | |
Functions | |
static bool | SHUTTING_DOWN () |
static void | dict_stats_recalc_pool_init () |
Initialize the recalc pool, called once during thread initialization. More... | |
static void | dict_stats_recalc_pool_deinit () |
Free the resources occupied by the recalc pool, called once during thread de-initialization. More... | |
void | dict_stats_recalc_pool_add (const dict_table_t *table) |
Add a table to the recalc pool, which is processed by the background stats gathering thread. More... | |
static bool | dict_stats_recalc_pool_get (table_id_t *id) |
Get a table from the auto recalc pool. More... | |
void | dict_stats_recalc_pool_del (const dict_table_t *table) |
Delete a given table from the auto recalc pool. More... | |
void | dict_stats_wait_bg_to_stop_using_table (dict_table_t *table, trx_t *trx) |
Wait until background stats thread has stopped using the specified table. More... | |
void | dict_stats_thread_init () |
Initialize global variables needed for the operation of dict_stats_thread() Must be called before dict_stats_thread() is started. More... | |
void | dict_stats_thread_deinit () |
Free resources allocated by dict_stats_thread_init(), must be called after dict_stats_thread() has exited. More... | |
static void | dict_stats_process_entry_from_recalc_pool (THD *thd) |
Get the first table that has been added for auto recalc and eventually update its stats. More... | |
void | dict_stats_disabled_debug_update (THD *, SYS_VAR *, void *, const void *save) |
Disables dict stats thread. More... | |
void | dict_stats_thread () |
This is the thread for background stats gathering. More... | |
void | dict_stats_shutdown () |
Shutdown the dict stats thread. More... | |
Variables | |
constexpr std::chrono::seconds | MIN_RECALC_INTERVAL {10} |
Minimum time interval between stats recalc for a given table. More... | |
os_event_t | dict_stats_event = nullptr |
Event to wake up the stats thread. More... | |
bool | innodb_dict_stats_disabled_debug |
Used by SET GLOBAL innodb_dict_stats_disabled_debug = 1;. More... | |
static os_event_t | dict_stats_disabled_event |
static ib_mutex_t | recalc_pool_mutex |
This mutex protects the "recalc_pool" variable. More... | |
static const ulint | RECALC_POOL_INITIAL_SLOTS = 128 |
The number of tables that can be added to "recalc_pool" before it is enlarged. More... | |
static recalc_pool_t * | recalc_pool |
Pool where we store information on which tables are to be processed by background statistics gathering. More... | |
Code used for background table and index stats gathering.
Created Apr 25, 2012 Vasil Dimov
Allocator type, used by std::vector.
typedef recalc_pool_t::iterator recalc_pool_iterator_t |
Iterator type for iterating over the elements of objects of type recalc_pool_t.
typedef std::vector<table_id_t, recalc_pool_allocator_t> recalc_pool_t |
The multitude of tables whose stats are to be automatically recalculated - an STL vector.
void dict_stats_disabled_debug_update | ( | THD * | thd, |
SYS_VAR * | var, | ||
void * | var_ptr, | ||
const void * | save | ||
) |
Disables dict stats thread.
It's used by: SET GLOBAL innodb_dict_stats_disabled_debug = 1 (0).
[in] | thd | thread handle |
[in] | var | pointer to system variable |
[out] | var_ptr | where the formal string goes |
[in] | save | immediate result from check function |
|
static |
Get the first table that has been added for auto recalc and eventually update its stats.
[in,out] | thd | current thread |
void dict_stats_recalc_pool_add | ( | const dict_table_t * | table | ) |
Add a table to the recalc pool, which is processed by the background stats gathering thread.
Only the table id is added to the list, so the table can be closed after being enqueued and it will be opened when needed. If the table does not exist later (has been DROPped), then it will be removed from the pool and skipped.
table | in: table to add |
|
static |
Free the resources occupied by the recalc pool, called once during thread de-initialization.
void dict_stats_recalc_pool_del | ( | const dict_table_t * | table | ) |
Delete a given table from the auto recalc pool.
dict_stats_recalc_pool_del()
table | in: table to remove |
|
static |
Get a table from the auto recalc pool.
The returned table id is removed from the pool.
id | out: table id, or unmodified if list is empty |
|
static |
Initialize the recalc pool, called once during thread initialization.
void dict_stats_shutdown | ( | ) |
Shutdown the dict stats thread.
void dict_stats_thread | ( | ) |
This is the thread for background stats gathering.
It pops tables, from the auto recalc list and proceeds them, eventually recalculating their statistics.
void dict_stats_thread_deinit | ( | ) |
Free resources allocated by dict_stats_thread_init(), must be called after dict_stats_thread() has exited.
void dict_stats_thread_init | ( | ) |
Initialize global variables needed for the operation of dict_stats_thread() Must be called before dict_stats_thread() is started.
Initialize global variables needed for the operation of dict_stats_thread().
void dict_stats_wait_bg_to_stop_using_table | ( | dict_table_t * | table, |
trx_t * | trx | ||
) |
Wait until background stats thread has stopped using the specified table.
The caller must have locked the data dictionary using row_mysql_lock_data_dictionary() and this function may unlock it temporarily and restore the lock before it exits. The background stats thread is guaranteed not to start using the specified table after this function returns and before the caller unlocks the data dictionary because it sets the BG_STAT_IN_PROGRESS bit in table->stats_bg_flag under dict_sys->mutex.
table | in/out: table |
trx | in/out: transaction to use for unlocking/locking the data dict |
|
inlinestatic |
|
static |
os_event_t dict_stats_event = nullptr |
Event to wake up the stats thread.
bool innodb_dict_stats_disabled_debug |
Used by SET GLOBAL innodb_dict_stats_disabled_debug = 1;.
Value of MySQL global used to disable dict_stats thread.
|
constexpr |
Minimum time interval between stats recalc for a given table.
|
static |
Pool where we store information on which tables are to be processed by background statistics gathering.
|
static |
The number of tables that can be added to "recalc_pool" before it is enlarged.
|
static |
This mutex protects the "recalc_pool" variable.