MySQL 8.0.29
Source Code Documentation
cost_model.h File Reference

Go to the source code of this file.

Classes

struct  FilterCost
 See EstimateFilterCost. More...
 

Functions

void AddCost (THD *thd, const ContainedSubquery &subquery, double num_rows, FilterCost *cost)
 Used internally by EstimateFilterCost() only. More...
 
FilterCost EstimateFilterCost (THD *thd, double num_rows, Item *condition, Query_block *outer_query_block)
 Estimate the cost of evaluating “condition”, “num_rows” times. More...
 
FilterCost EstimateFilterCost (THD *thd, double num_rows, const Mem_root_array< ContainedSubquery > &contained_subqueries)
 A cheaper overload of EstimateFilterCost() that assumes that all contained subqueries have already been extracted (ie., it skips the walking, which can be fairly expensive). More...
 
double EstimateCostForRefAccess (THD *thd, TABLE *table, unsigned key_idx, double num_output_rows)
 
void EstimateSortCost (AccessPath *path, ha_rows limit_rows=HA_POS_ERROR)
 
void EstimateMaterializeCost (THD *thd, AccessPath *path)
 
void EstimateAggregateCost (AccessPath *path, const Query_block *query_block)
 
void EstimateDeleteRowsCost (AccessPath *path)
 
double FindOutputRowsForJoin (double left_rows, double right_rows, const JoinPredicate *edge)
 

Variables

constexpr double kApplyOneFilterCost = 0.1
 
constexpr double kAggregateOneRowCost = 0.1
 
constexpr double kSortOneRowCost = 0.1
 
constexpr double kHashBuildOneRowCost = 0.1
 
constexpr double kHashProbeOneRowCost = 0.1
 
constexpr double kHashReturnOneRowCost = 0.07
 
constexpr double kMaterializeOneRowCost = 0.1
 
constexpr double kWindowOneRowCost = 0.1
 

Function Documentation

◆ AddCost()

void AddCost ( THD thd,
const ContainedSubquery subquery,
double  num_rows,
FilterCost cost 
)

Used internally by EstimateFilterCost() only.

◆ EstimateAggregateCost()

void EstimateAggregateCost ( AccessPath path,
const Query_block query_block 
)

◆ EstimateCostForRefAccess()

double EstimateCostForRefAccess ( THD thd,
TABLE table,
unsigned  key_idx,
double  num_output_rows 
)

◆ EstimateDeleteRowsCost()

void EstimateDeleteRowsCost ( AccessPath path)

◆ EstimateFilterCost() [1/2]

FilterCost EstimateFilterCost ( THD thd,
double  num_rows,
const Mem_root_array< ContainedSubquery > &  contained_subqueries 
)
inline

A cheaper overload of EstimateFilterCost() that assumes that all contained subqueries have already been extracted (ie., it skips the walking, which can be fairly expensive).

This data is typically computed by FindContainedSubqueries().

◆ EstimateFilterCost() [2/2]

FilterCost EstimateFilterCost ( THD thd,
double  num_rows,
Item condition,
Query_block outer_query_block 
)

Estimate the cost of evaluating “condition”, “num_rows” times.

This is a fairly rudimentary estimation, but it includes the cost of any subqueries that may be present and that need evaluation.

◆ EstimateMaterializeCost()

void EstimateMaterializeCost ( THD thd,
AccessPath path 
)

◆ EstimateSortCost()

void EstimateSortCost ( AccessPath path,
ha_rows  limit_rows = HA_POS_ERROR 
)

◆ FindOutputRowsForJoin()

double FindOutputRowsForJoin ( double  left_rows,
double  right_rows,
const JoinPredicate edge 
)
inline

Variable Documentation

◆ kAggregateOneRowCost

constexpr double kAggregateOneRowCost = 0.1
constexpr

◆ kApplyOneFilterCost

constexpr double kApplyOneFilterCost = 0.1
constexpr

◆ kHashBuildOneRowCost

constexpr double kHashBuildOneRowCost = 0.1
constexpr

◆ kHashProbeOneRowCost

constexpr double kHashProbeOneRowCost = 0.1
constexpr

◆ kHashReturnOneRowCost

constexpr double kHashReturnOneRowCost = 0.07
constexpr

◆ kMaterializeOneRowCost

constexpr double kMaterializeOneRowCost = 0.1
constexpr

◆ kSortOneRowCost

constexpr double kSortOneRowCost = 0.1
constexpr

◆ kWindowOneRowCost

constexpr double kWindowOneRowCost = 0.1
constexpr