MySQL 8.4.2
Source Code Documentation
|
This class implements a cache for "cost constant sets". More...
#include <opt_costconstantcache.h>
Public Member Functions | |
~Cost_constant_cache () | |
Destructor for the cost constant cache. More... | |
void | init () |
Initialize the cost module. More... | |
void | close () |
Close the cost constant cache. More... | |
void | reload () |
Reload all cost constants from the configuration tables. More... | |
const Cost_model_constants * | get_cost_constants () |
Get the currently used set of cost constants. More... | |
const Cost_model_constants * | get_cost_constants_hypergraph () |
void | release_cost_constants (const Cost_model_constants *cost_constants) |
Releases the cost constant set. More... | |
Private Member Functions | |
Cost_model_constants * | create_defaults (Optimizer optimizer) const |
Create default cost constants. More... | |
void | update_current_cost_constants (Cost_model_constants *new_cost_constants, Optimizer optimizer) |
Replace the current cost constants with a new set of cost constants. More... | |
Private Attributes | |
Cost_model_constants * | current_cost_constants = nullptr |
The current set of cost constants that will be used by new sessions. More... | |
Cost_model_constants * | current_cost_constants_hypergraph = nullptr |
The current set of cost constants that will be used with the hypergraph optimizer by new sessions. More... | |
mysql_mutex_t | LOCK_cost_const |
Mutex protecting the pointer to the current cost constant set and reference counting on all cost constant sets. More... | |
bool | m_inited = false |
This class implements a cache for "cost constant sets".
This cache is responsible for creating the set of cost constant, giving new sessions access to the latest versions of the cost constants, and for re-reading the cost constant tables in the case where these have been updated.
To initialize the cost constant cache with default cost constants, init()
must be called. To load cost constants from the mysql.server_cost and mysql.engine_cost tables, reload()
must be called.
The cost constant cache keeps a copy of the current set of cost constants. Each time a new session initializes its Cost_model_server object (by calling Cost_model_server::init() in lex_start()), the Cost_model_server object will request the cost constant cache to give it the current version of the cost constants. This is done by calling Cost_constant_cache::get_cost_constants(). This function will just return a pointer to the current set of cost constants. As time goes, new cost constant sets might be created and added to the cost constant cache. In order to know when a cost constant set can be deleted, reference counting is used. Each time a session asks for the cost constants, the reference counter is incremented. When the session releases the cost constant set by calling release_cost_constants()
, the reference counter will be decremented. When the reference counter becomes zero, the cost constant set is deleted.
Cost_constant_cache::~Cost_constant_cache | ( | ) |
Destructor for the cost constant cache.
Before the cost constant cache is deleted, close()
must have been called.
void Cost_constant_cache::close | ( | void | ) |
Close the cost constant cache.
All resources owned by the cost constant cache are released.
|
private |
Create default cost constants.
This will create cost constants based on default values defined in the source code.
|
inline |
Get the currently used set of cost constants.
This function will just return a pointer to a shared version of the cost constants. For tracking of how many sessions that is using the set and to be able to know when it is safe to delete the cost constant object, reference counting is used. This function will increase the ref count for the returned cost constant object. To decrease the reference counter when the cost constants are no longer used, release_cost_constants()
must be called.
|
inline |
void Cost_constant_cache::init | ( | ) |
Initialize the cost module.
The cost constants will be initialized with the default values found in the source code. To start using the cost constant values found in the configuration tables, the reload()
function must be called.
|
inline |
Releases the cost constant set.
This will decrement the reference counter on the cost constant set and if nobody is using it, it will be deleted. This function should be called each time a client (a session) no longer has any use for a cost constant set that it has previously gotten from calling get_cost_constants()
cost_constants | pointer to the cost constant set |
void Cost_constant_cache::reload | ( | ) |
Reload all cost constants from the configuration tables.
|
private |
Replace the current cost constants with a new set of cost constants.
new_cost_constants | The new cost constants. |
optimizer | The optimizer to update cost constants for. |
|
private |
The current set of cost constants that will be used by new sessions.
|
private |
The current set of cost constants that will be used with the hypergraph optimizer by new sessions.
|
private |
Mutex protecting the pointer to the current cost constant set and reference counting on all cost constant sets.
|
private |