MySQL 8.4.3
Source Code Documentation
Cost_model_server Class Reference

API for getting cost estimates for server operations that are not directly related to a table object. More...

#include <opt_costmodel.h>

Public Types

enum  enum_tmptable_type { MEMORY_TMPTABLE , DISK_TMPTABLE }
 Temporary table types that the cost model differentiate between. More...
 

Public Member Functions

 Cost_model_server ()
 
virtual ~Cost_model_server ()
 Destructor for Cost_model_server objects. More...
 
void init (Optimizer optimizer)
 Initialize the cost model object for a query. More...
 
double row_evaluate_cost (double rows) const
 Cost of processing a number of records and evaluating the query condition on the records. More...
 
double key_compare_cost (double keys) const
 Cost of doing a number of key compare operations. More...
 
double tmptable_create_cost (enum_tmptable_type tmptable_type) const
 Cost estimate for creating a temporary table. More...
 
double tmptable_readwrite_cost (enum_tmptable_type tmptable_type, double write_rows, double read_rows) const
 Cost estimate for inserting and reading records from a temporary table. More...
 

Protected Member Functions

const Cost_model_constantsget_cost_constants () const
 Return a pointer to the object containing the current cost constants. More...
 

Protected Attributes

const Server_cost_constantsm_server_cost_constants
 
bool m_initialized
 Used for detecting if this object is used without having been initialized. More...
 

Private Member Functions

double memory_tmptable_create_cost () const
 Cost of creating a temporary table in the memory storage engine. More...
 
double memory_tmptable_row_cost () const
 Cost of storing or retrieving a row using the memory storage engine. More...
 
double disk_tmptable_create_cost () const
 Cost of creating a temporary table using a disk based storage engine. More...
 
double disk_tmptable_row_cost () const
 Cost of storing or retrieving a row using a disk based storage engine. More...
 
double tmptable_row_cost (enum_tmptable_type tmptable_type) const
 Cost estimate for a row operation (insert, read) on a temporary table. More...
 

Private Attributes

const Cost_model_constantsm_cost_constants
 Cost constants to use in cost calculations. More...
 

Friends

class Cost_model_table
 

Detailed Description

API for getting cost estimates for server operations that are not directly related to a table object.

Member Enumeration Documentation

◆ enum_tmptable_type

Temporary table types that the cost model differentiate between.

Enumerator
MEMORY_TMPTABLE 
DISK_TMPTABLE 

Constructor & Destructor Documentation

◆ Cost_model_server()

Cost_model_server::Cost_model_server ( )
inline

◆ ~Cost_model_server()

Cost_model_server::~Cost_model_server ( )
virtual

Destructor for Cost_model_server objects.

Note
This is declared virtual in order to make it easier to implement stubs for this class for use in unit tests.

Member Function Documentation

◆ disk_tmptable_create_cost()

double Cost_model_server::disk_tmptable_create_cost ( ) const
inlineprivate

Cost of creating a temporary table using a disk based storage engine.

◆ disk_tmptable_row_cost()

double Cost_model_server::disk_tmptable_row_cost ( ) const
inlineprivate

Cost of storing or retrieving a row using a disk based storage engine.

◆ get_cost_constants()

const Cost_model_constants * Cost_model_server::get_cost_constants ( ) const
inlineprotected

Return a pointer to the object containing the current cost constants.

Returns
Cost constants

◆ init()

void Cost_model_server::init ( Optimizer  optimizer)

Initialize the cost model object for a query.

This function must be called before calling any cost estimation functions for a query. It should also be called when starting optimization of a new query in case any cost estimate constants have changed.

Parameters
optimizerThe type of optimizer to initialize the cost model for.

◆ key_compare_cost()

double Cost_model_server::key_compare_cost ( double  keys) const
inline

Cost of doing a number of key compare operations.

Parameters
keysnumber of key compare operations
Returns
Cost of comparing the keys

◆ memory_tmptable_create_cost()

double Cost_model_server::memory_tmptable_create_cost ( ) const
inlineprivate

Cost of creating a temporary table in the memory storage engine.

◆ memory_tmptable_row_cost()

double Cost_model_server::memory_tmptable_row_cost ( ) const
inlineprivate

Cost of storing or retrieving a row using the memory storage engine.

◆ row_evaluate_cost()

double Cost_model_server::row_evaluate_cost ( double  rows) const
inline

Cost of processing a number of records and evaluating the query condition on the records.

Parameters
rowsnumber of rows to evaluate
Returns
Cost of evaluating the records

◆ tmptable_create_cost()

double Cost_model_server::tmptable_create_cost ( enum_tmptable_type  tmptable_type) const
inline

Cost estimate for creating a temporary table.

Parameters
tmptable_typestorage type for the temporary table
Returns
Cost estimate

◆ tmptable_readwrite_cost()

double Cost_model_server::tmptable_readwrite_cost ( enum_tmptable_type  tmptable_type,
double  write_rows,
double  read_rows 
) const
inline

Cost estimate for inserting and reading records from a temporary table.

Parameters
tmptable_typestorage type for the temporary table
write_rowsnumber of rows that will be written to table
read_rowsnumber of rows that will be read from table
Returns
The estimated cost

◆ tmptable_row_cost()

double Cost_model_server::tmptable_row_cost ( enum_tmptable_type  tmptable_type) const
inlineprivate

Cost estimate for a row operation (insert, read) on a temporary table.

Parameters
tmptable_typestorage type for the temporary table
Returns
The estimated cost

Friends And Related Function Documentation

◆ Cost_model_table

friend class Cost_model_table
friend

Member Data Documentation

◆ m_cost_constants

const Cost_model_constants* Cost_model_server::m_cost_constants
private

Cost constants to use in cost calculations.

◆ m_initialized

bool Cost_model_server::m_initialized
protected

Used for detecting if this object is used without having been initialized.

◆ m_server_cost_constants

const Server_cost_constants* Cost_model_server::m_server_cost_constants
protected

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