23#ifndef SQL_JOIN_OPTIMIZER_COST_MODEL_H_
24#define SQL_JOIN_OPTIMIZER_COST_MODEL_H_
105 THD *thd,
double num_rows,
112 AddCost(thd, subquery, num_rows, &cost);
118 double num_output_rows);
131 std::string *trace =
nullptr);
139 std::string *trace =
nullptr);
151 const auto aggregated_right_rows = [&]() {
163 fanout = std::max(right_rows * edge->
selectivity, 1.0);
183 fanout = std::min(1.0, aggregated_right_rows() * edge->
selectivity);
189 fanout = std::max(1.0 - aggregated_right_rows() * edge->
selectivity, 0.1);
193 return left_rows * fanout;
A wrapper class which provides array bounds checking.
Definition: sql_array.h:46
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:853
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:425
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1162
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
constexpr double kHashReturnOneRowCost
Definition: cost_model.h:54
constexpr ha_rows kRowEstimateFallback
A fallback cardinality estimate that is used in case the storage engine cannot provide one (like for ...
Definition: cost_model.h:61
double EstimateAggregateRows(double child_rows, Bounds_checked_array< const Item *const > aggregate_terms, std::string *trace=nullptr)
Estimate the number of output rows for an aggregate operation.
double FindOutputRowsForJoin(double left_rows, double right_rows, const JoinPredicate *edge)
Definition: cost_model.h:149
constexpr size_t kMaxItemLengthEstimate
When we make cost estimates, we use this as the maximal length the values we get from evaluating an I...
Definition: cost_model.h:44
void EstimateAggregateCost(AccessPath *path, const Query_block *query_block, std::string *trace=nullptr)
Estimate costs and result row count for an aggregate operation.
void AddCost(THD *thd, const ContainedSubquery &subquery, double num_rows, FilterCost *cost)
Used internally by EstimateFilterCost() only.
Definition: cost_model.cc:122
constexpr double kHashBuildOneRowCost
Definition: cost_model.h:52
void EstimateLimitOffsetCost(AccessPath *path)
Estimate the costs and row count for a LIMIT_OFFSET AccessPath.
Definition: cost_model.cc:901
constexpr double kWindowOneRowCost
Definition: cost_model.h:56
constexpr double kApplyOneFilterCost
Definition: cost_model.h:49
void EstimateDeleteRowsCost(AccessPath *path)
Definition: cost_model.cc:851
constexpr double kMaterializeOneRowCost
Definition: cost_model.h:55
void EstimateStreamCost(AccessPath *path)
Estimate the costs and row count for a STREAM AccessPath.
Definition: cost_model.cc:885
double EstimateCostForRefAccess(THD *thd, TABLE *table, unsigned key_idx, double num_output_rows)
Definition: cost_model.cc:58
void EstimateUpdateRowsCost(AccessPath *path)
Definition: cost_model.cc:868
void EstimateMaterializeCost(THD *thd, AccessPath *path)
Definition: cost_model.cc:178
constexpr double kHashProbeOneRowCost
Definition: cost_model.h:53
constexpr double kSortOneRowCost
Definition: cost_model.h:51
constexpr double kAggregateOneRowCost
Definition: cost_model.h:50
FilterCost EstimateFilterCost(THD *thd, double num_rows, Item *condition, const Query_block *outer_query_block)
Estimate the cost of evaluating “condition”, “num_rows” times.
Definition: cost_model.cc:163
void EstimateSortCost(AccessPath *path)
Definition: cost_model.cc:91
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1139
static char * path
Definition: mysqldump.cc:140
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:193
This class represents a subquery contained in some subclass of Item_subselect,.
Definition: item.h:785
See EstimateFilterCost.
Definition: cost_model.h:64
double init_cost_if_not_materialized
Initial cost before the filter can be applied for the first time.
Definition: cost_model.h:74
double cost_to_materialize
Cost of materializing all subqueries present in the filter.
Definition: cost_model.h:83
double cost_if_materialized
Cost of evaluating the filter for all rows if all subqueries in it have been materialized beforehand.
Definition: cost_model.h:79
double cost_if_not_materialized
Cost of evaluating the filter for all rows if subqueries are not materialized.
Definition: cost_model.h:68
A specification that two specific relational expressions (e.g., two tables, or a table and a join bet...
Definition: access_path.h:76
int semijoin_group_size
Definition: access_path.h:109
RelationalExpression * expr
Definition: access_path.h:77
double selectivity
Definition: access_path.h:78
Item ** semijoin_group
Definition: access_path.h:108
enum RelationalExpression::Type type
@ SEMIJOIN
Definition: relational_expression.h:148
@ ANTIJOIN
Definition: relational_expression.h:149
@ LEFT_JOIN
Definition: relational_expression.h:147