MySQL 9.1.0
Source Code Documentation
Cost_model_table Class Reference

API for getting cost estimates for operations on table data. More...

#include <opt_costmodel.h>

Public Member Functions

 Cost_model_table ()
 
void init (const Cost_model_server *cost_model_server, const TABLE *table)
 Initializes the cost model object. 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 io_block_read_cost (double blocks) const
 Cost of reading a number of random blocks from a table. More...
 
double buffer_block_read_cost (double blocks) const
 Cost of reading a number of blocks from the storage engine when the block is already in a memory buffer. More...
 
double page_read_cost (double pages) const
 Cost of reading a number of random pages from a table. More...
 
double page_read_cost_index (uint index, double pages) const
 Cost of reading a number of random pages from an index. More...
 
double disk_seek_base_cost () const
 The fixed part of the cost for doing a sequential seek on disk. More...
 
double disk_seek_cost (double seek_blocks) const
 Cost estimate for a sequential disk seek where a given number of blocks are skipped. More...
 

Protected Attributes

const Cost_model_serverm_cost_model_server
 Pointer to the cost model for the query. More...
 
const SE_cost_constantsm_se_cost_constants
 Cost constants for the storage engine that stores the table. More...
 
bool m_initialized
 Used for detecting if this object is used without having been initialized. More...
 

Private Member Functions

double disk_seek_prop_cost () const
 The cost for seeking past one block in a sequential seek. More...
 

Private Attributes

const TABLEm_table
 The table that this is the cost model for. More...
 

Detailed Description

API for getting cost estimates for operations on table data.

Note
The initial implementation mostly has functions for accessing cost constants for basic operations.

Constructor & Destructor Documentation

◆ Cost_model_table()

Cost_model_table::Cost_model_table ( )
inline

Member Function Documentation

◆ buffer_block_read_cost()

double Cost_model_table::buffer_block_read_cost ( double  blocks) const
inline

Cost of reading a number of blocks from the storage engine when the block is already in a memory buffer.

Parameters
blocksnumber of blocks to read
Returns
Cost estimate

◆ disk_seek_base_cost()

double Cost_model_table::disk_seek_base_cost ( ) const
inline

The fixed part of the cost for doing a sequential seek on disk.

For a harddisk, this corresponds to half a rotation (see comment for get_sweep_read_cost() in handler.cc).

◆ disk_seek_cost()

double Cost_model_table::disk_seek_cost ( double  seek_blocks) const
inline

Cost estimate for a sequential disk seek where a given number of blocks are skipped.

Parameters
seek_blocksnumber of blocks to seek past
Returns
The cost estimate for the seek operation

◆ disk_seek_prop_cost()

double Cost_model_table::disk_seek_prop_cost ( ) const
inlineprivate

The cost for seeking past one block in a sequential seek.

For a harddisk, this represents the cost of having to move the disk head to the correct cylinder.

◆ init()

void Cost_model_table::init ( const Cost_model_server cost_model_server,
const TABLE table 
)

Initializes the cost model object.

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
cost_model_serverthe main cost model object for this query
tablethe table the cost model should be used for

◆ io_block_read_cost()

double Cost_model_table::io_block_read_cost ( double  blocks) const
inline

Cost of reading a number of random blocks from a table.

Parameters
blocksnumber of blocks to read
Returns
Cost estimate

◆ key_compare_cost()

double Cost_model_table::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

◆ page_read_cost()

double Cost_model_table::page_read_cost ( double  pages) const

Cost of reading a number of random pages from a table.

Parameters
pagesnumber of pages to read
Returns
Cost estimate

◆ page_read_cost_index()

double Cost_model_table::page_read_cost_index ( uint  index,
double  pages 
) const

Cost of reading a number of random pages from an index.

Parameters
indexthe index number
pagesnumber of pages to read
Returns
Cost estimate

◆ row_evaluate_cost()

double Cost_model_table::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

Member Data Documentation

◆ m_cost_model_server

const Cost_model_server* Cost_model_table::m_cost_model_server
protected

Pointer to the cost model for the query.

This is used for getting cost estimates for server operations.

◆ m_initialized

bool Cost_model_table::m_initialized
protected

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

◆ m_se_cost_constants

const SE_cost_constants* Cost_model_table::m_se_cost_constants
protected

Cost constants for the storage engine that stores the table.

◆ m_table

const TABLE* Cost_model_table::m_table
private

The table that this is the cost model for.


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