MySQL 9.1.0
Source Code Documentation
CostOfItem Class Referencefinal

This class represents the cost of evaluating an Item. More...

#include <item.h>

Public Member Functions

void Compute (const Item &item)
 Set '*this' to represent the cost of 'item'. More...
 
void MarkExpensive ()
 
void AddStrFieldCost ()
 Add the cost of accessing a Field_str. More...
 
void AddFieldCost ()
 Add the cost of accessing any other Field. More...
 
bool IsExpensive () const
 
double FieldCost () const
 Get the cost of field access when evaluating the Item associated with this object. More...
 

Private Member Functions

void ComputeInternal (const Item &root)
 Compute the cost of 'root' and its descendants. More...
 

Private Attributes

bool m_computed {false}
 True if 'ComputeInternal()' has been called. More...
 
bool m_is_expensive {false}
 True if the associated Item calls user defined functions or stored procedures. More...
 
uint8 m_str_fields {0}
 The number of Field_str objects accessed by the associated Item. More...
 
uint8 m_other_fields {0}
 The number of other Field objects accessed by the associated Item. More...
 

Static Private Attributes

static constexpr double kStrFieldCost = 1.8
 The cost of accessing a Field_str, relative to other Field types. More...
 
static constexpr double kOtherFieldCost = 1.0
 The cost of accessing a Field other than Field_str. 1.0 by definition. More...
 

Detailed Description

This class represents the cost of evaluating an Item.

See also
SortPredicates to see how this is used.

Member Function Documentation

◆ AddFieldCost()

void CostOfItem::AddFieldCost ( )
inline

Add the cost of accessing any other Field.

◆ AddStrFieldCost()

void CostOfItem::AddStrFieldCost ( )
inline

Add the cost of accessing a Field_str.

◆ Compute()

void CostOfItem::Compute ( const Item item)
inline

Set '*this' to represent the cost of 'item'.

◆ ComputeInternal()

void CostOfItem::ComputeInternal ( const Item root)
private

Compute the cost of 'root' and its descendants.

◆ FieldCost()

double CostOfItem::FieldCost ( ) const
inline

Get the cost of field access when evaluating the Item associated with this object.

The cost unit is arbitrary, but the relative cost of different items reflect the fact that operating on Field_str is more expensive than other Field subclasses.

◆ IsExpensive()

bool CostOfItem::IsExpensive ( ) const
inline

◆ MarkExpensive()

void CostOfItem::MarkExpensive ( )
inline

Member Data Documentation

◆ kOtherFieldCost

constexpr double CostOfItem::kOtherFieldCost = 1.0
staticconstexprprivate

The cost of accessing a Field other than Field_str. 1.0 by definition.

◆ kStrFieldCost

constexpr double CostOfItem::kStrFieldCost = 1.8
staticconstexprprivate

The cost of accessing a Field_str, relative to other Field types.

(The value was determined using benchmarks.)

◆ m_computed

bool CostOfItem::m_computed {false}
private

True if 'ComputeInternal()' has been called.

◆ m_is_expensive

bool CostOfItem::m_is_expensive {false}
private

True if the associated Item calls user defined functions or stored procedures.

◆ m_other_fields

uint8 CostOfItem::m_other_fields {0}
private

The number of other Field objects accessed by the associated Item.

◆ m_str_fields

uint8 CostOfItem::m_str_fields {0}
private

The number of Field_str objects accessed by the associated Item.


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