MySQL 9.0.0
Source Code Documentation
Cost_model_constants Class Reference

Set of all cost constants used by the server and all storage engines. More...

#include <opt_costconstants.h>

Public Member Functions

 Cost_model_constants (Optimizer optimizer)
 Creates a set with cost constants using the default values defined in the source code. More...
 
virtual ~Cost_model_constants ()
 Destructor. More...
 
const Server_cost_constantsget_server_cost_constants () const
 Get the cost constants that should be used for server operations. More...
 
const SE_cost_constantsget_se_cost_constants (const TABLE *table) const
 Return the cost constants that should be used for a given table. More...
 
cost_constant_error update_server_cost_constant (const LEX_CSTRING &name, double value)
 Update the value for one of the server cost constants. More...
 
cost_constant_error update_engine_cost_constant (THD *thd, const LEX_CSTRING &se_name, uint storage_category, const LEX_CSTRING &name, double value)
 Update the value for one of the storage engine cost constants. More...
 

Protected Member Functions

void inc_ref_count ()
 Increment the reference counter for this cost constant set. More...
 
unsigned int dec_ref_count ()
 Decrement the reference counter for this cost constant set. More...
 

Private Member Functions

virtual uint find_handler_slot_from_name (THD *thd, const LEX_CSTRING &name) const
 Utility function for finding the slot number for a storage engine based on the storage engine name. More...
 
cost_constant_error update_engine_default_cost (const LEX_CSTRING &name, uint storage_category, double value)
 Update the default value for a storage engine cost constant. More...
 

Private Attributes

Server_cost_constants m_server_constants
 Cost constants for server operations. More...
 
Prealloced_array< Cost_model_se_info, 15 > m_engines
 Cost constants for storage engines 15 should be enough for most use cases, see PREALLOC_NUM_HA. More...
 
unsigned int m_ref_counter
 Reference counter for this set of cost constants. More...
 
Optimizer m_optimizer
 Optimizer type. More...
 

Friends

class Cost_constant_cache
 

Detailed Description

Set of all cost constants used by the server and all storage engines.

Constructor & Destructor Documentation

◆ Cost_model_constants()

Cost_model_constants::Cost_model_constants ( Optimizer  optimizer)

Creates a set with cost constants using the default values defined in the source code.

Create default cost constants for each storage engine.

◆ ~Cost_model_constants()

Cost_model_constants::~Cost_model_constants ( )
virtual

Destructor.

Note
The only reason for making this virtual is to be able to make a sub-class for use in unit testing.

Member Function Documentation

◆ dec_ref_count()

unsigned int Cost_model_constants::dec_ref_count ( )
inlineprotected

Decrement the reference counter for this cost constant set.

When the returned value is zero, there is nobody using this object and it can be deleted by the caller.

Returns
the updated reference count

◆ find_handler_slot_from_name()

uint Cost_model_constants::find_handler_slot_from_name ( THD thd,
const LEX_CSTRING name 
) const
privatevirtual

Utility function for finding the slot number for a storage engine based on the storage engine name.

The only reason for making this function virtual is to be able to override it in unit tests.

Parameters
thdthe THD
namename of storage engine
Returns
slot number for the storage engine, HA_SLOT_UNDEF if there is no handler for this name

◆ get_se_cost_constants()

const SE_cost_constants * Cost_model_constants::get_se_cost_constants ( const TABLE table) const

Return the cost constants that should be used for a given table.

Parameters
tablethe table to find cost constants for
Returns
the cost constants to use for the table

◆ get_server_cost_constants()

const Server_cost_constants * Cost_model_constants::get_server_cost_constants ( ) const
inline

Get the cost constants that should be used for server operations.

Returns
the cost constants for the server

◆ inc_ref_count()

void Cost_model_constants::inc_ref_count ( )
inlineprotected

Increment the reference counter for this cost constant set.

◆ update_engine_cost_constant()

cost_constant_error Cost_model_constants::update_engine_cost_constant ( THD thd,
const LEX_CSTRING se_name,
uint  storage_category,
const LEX_CSTRING name,
double  value 
)

Update the value for one of the storage engine cost constants.

Parameters
thdthe THD
se_namename of storage engine
storage_categorystorage device type
namename of cost constant
valuenew value
Returns
Status for updating the cost constant

◆ update_engine_default_cost()

cost_constant_error Cost_model_constants::update_engine_default_cost ( const LEX_CSTRING name,
uint  storage_category,
double  value 
)
private

Update the default value for a storage engine cost constant.

Parameters
namename of cost constant
storage_categorystorage device type
valuenew value
Returns
Status for updating the cost constant

◆ update_server_cost_constant()

cost_constant_error Cost_model_constants::update_server_cost_constant ( const LEX_CSTRING name,
double  value 
)

Update the value for one of the server cost constants.

Parameters
namename of the cost constant
valuenew value
Returns
Status for updating the cost constant

Friends And Related Function Documentation

◆ Cost_constant_cache

friend class Cost_constant_cache
friend

Member Data Documentation

◆ m_engines

Prealloced_array<Cost_model_se_info, 15> Cost_model_constants::m_engines
private

Cost constants for storage engines 15 should be enough for most use cases, see PREALLOC_NUM_HA.

◆ m_optimizer

Optimizer Cost_model_constants::m_optimizer
private

Optimizer type.

◆ m_ref_counter

unsigned int Cost_model_constants::m_ref_counter
private

Reference counter for this set of cost constants.

◆ m_server_constants

Server_cost_constants Cost_model_constants::m_server_constants
private

Cost constants for server operations.


The documentation for this class was generated from the following files: