My Project
|
#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.
bool Table_cache::add_used_table | ( | THD * | thd, |
TABLE * | table | ||
) | [inline] |
Add newly created TABLE object which is going to be used right away to the table cache.
false | - success. |
true | - failure. |
void Table_cache::assert_owner | ( | ) | [inline] |
Assert that caller owns lock on the table cache.
uint Table_cache::cached_tables | ( | ) | const [inline] |
Get number of TABLE instances in the cache.
void Table_cache::destroy | ( | ) |
Destroy instance of table cache.
void Table_cache::free_all_unused_tables | ( | ) |
Free all unused TABLE objects in the table cache.
TABLE * Table_cache::get_table | ( | THD * | thd, |
my_hash_value_type | hash_value, | ||
const char * | key, | ||
uint | key_length, | ||
TABLE_SHARE ** | share | ||
) | [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. |
bool Table_cache::init | ( | void | ) |
Initialize instance of table cache.
false | - success. |
true | - failure. |
void Table_cache::init_psi_keys | ( | ) | [static] |
Init P_S instrumentation key for mutex protecting Table_cache instance.
void Table_cache::lock | ( | void | ) | [inline] |
Acquire lock on table cache instance.
void Table_cache::print_tables | ( | ) |
Print debug information for the contents of the table cache.
void Table_cache::release_table | ( | THD * | thd, |
TABLE * | table | ||
) | [inline] |
Put used TABLE instance back to the table cache and mark it as unused.
void Table_cache::remove_table | ( | TABLE * | table | ) | [inline] |
Prepare used or unused TABLE instance for destruction by removing it from the table cache.
void Table_cache::unlock | ( | void | ) | [inline] |
Release lock on table cache instance.