MySQL 5.6.14 Source Code Document
|
#include <table_cache.h>
Public Member Functions | |
bool | init () |
void | destroy () |
void | lock () |
void | unlock () |
void | assert_owner () |
TABLE * | get_table (THD *thd, my_hash_value_type hash_value, const char *key, uint key_length, TABLE_SHARE **share) |
void | release_table (THD *thd, TABLE *table) |
bool | add_used_table (THD *thd, TABLE *table) |
void | remove_table (TABLE *table) |
uint | cached_tables () const |
void | free_all_unused_tables () |
void | print_tables () |
Static Public Member Functions | |
static void | init_psi_keys () |
Cache for open TABLE objects.
The idea behind this cache is that most statements don't need to go to a central table definition cache to get a TABLE object and therefore don't need to lock LOCK_open mutex. Instead they only need to go to one Table_cache instance (the specific instance is determined by thread id) and only lock the mutex protecting this cache. DDL statements that need to remove all TABLE objects from all caches need to lock mutexes for all Table_cache instances, but they are rare.
This significantly increases scalability in some scenarios.
Definition at line 38 of file table_cache.h.
|
inline |
Add newly created TABLE object which is going to be used right away to the table cache.
false | - success. |
true | - failure. |
Definition at line 346 of file table_cache.h.
|
inline |
Assert that caller owns lock on the table cache.
Definition at line 119 of file table_cache.h.
|
inline |
Get number of TABLE instances in the cache.
Definition at line 131 of file table_cache.h.
void Table_cache::destroy | ( | ) |
Destroy instance of table cache.
Definition at line 77 of file table_cache.cc.
void Table_cache::free_all_unused_tables | ( | ) |
Free all unused TABLE objects in the table cache.
Definition at line 151 of file table_cache.cc.
|
inline |
Get an unused TABLE instance from the table cache.
thd | Thread context. | |
hash_value | Hash value for the key identifying table. | |
key | Key identifying table. | |
key_length | Length of key for the table. | |
[out] | share | NULL - if table cache doesn't contain any information about the table (i.e. doesn't have neither used nor unused TABLE objects for it). Pointer to TABLE_SHARE for the table otherwise. |
non-NULL | - pointer to unused TABLE object, "share" out-parameter contains pointer to TABLE_SHARE for this table. |
NULL | - no unused TABLE object was found, "share" parameter contains pointer to TABLE_SHARE for this table if there are used TABLE objects in cache and NULL otherwise. |
Definition at line 461 of file table_cache.h.
bool Table_cache::init | ( | void | ) |
Initialize instance of table cache.
false | - success. |
true | - failure. |
Definition at line 57 of file table_cache.cc.
|
static |
Init P_S instrumentation key for mutex protecting Table_cache instance.
Definition at line 86 of file table_cache.cc.
|
inline |
Acquire lock on table cache instance.
Definition at line 115 of file table_cache.h.
void Table_cache::print_tables | ( | ) |
Print debug information for the contents of the table cache.
Definition at line 169 of file table_cache.cc.
|
inline |
Put used TABLE instance back to the table cache and mark it as unused.
Definition at line 516 of file table_cache.h.
|
inline |
Prepare used or unused TABLE instance for destruction by removing it from the table cache.
Definition at line 404 of file table_cache.h.
|
inline |
Release lock on table cache instance.
Definition at line 117 of file table_cache.h.