23#ifndef SQL_JOIN_OPTIMIZER_ACCESS_PATH_H
24#define SQL_JOIN_OPTIMIZER_ACCESS_PATH_H
538 return u.index_distance_scan;
542 return u.index_distance_scan;
554 return u.ref_or_null;
558 return u.ref_or_null;
570 return u.pushed_join_ref;
574 return u.pushed_join_ref;
578 return u.full_text_search;
582 return u.full_text_search;
586 return u.const_table;
590 return u.const_table;
602 return u.follow_tail;
606 return u.follow_tail;
610 return u.index_range_scan;
614 return u.index_range_scan;
618 return u.index_merge;
622 return u.index_merge;
626 return u.rowid_intersection;
630 return u.rowid_intersection;
634 return u.rowid_union;
638 return u.rowid_union;
642 return u.index_skip_scan;
646 return u.index_skip_scan;
650 return u.group_index_skip_scan;
654 return u.group_index_skip_scan;
658 return u.dynamic_index_range_scan;
662 return u.dynamic_index_range_scan;
666 return u.materialized_table_function;
670 return u.materialized_table_function;
674 return u.unqualified_count;
678 return u.unqualified_count;
682 return u.table_value_constructor;
686 return u.table_value_constructor;
690 return u.fake_single_row;
694 return u.fake_single_row;
706 return u.zero_rows_aggregated;
710 return u.zero_rows_aggregated;
730 return u.nested_loop_join;
734 return u.nested_loop_join;
738 return u.nested_loop_semijoin_with_duplicate_removal;
742 return u.nested_loop_semijoin_with_duplicate_removal;
770 return u.temptable_aggregate;
774 return u.temptable_aggregate;
778 return u.limit_offset;
782 return u.limit_offset;
794 return u.materialize;
798 return u.materialize;
802 return u.materialize_information_schema_table;
806 return u.materialize_information_schema_table;
834 return u.remove_duplicates;
838 return u.remove_duplicates;
842 return u.remove_duplicates_on_index;
846 return u.remove_duplicates_on_index;
850 return u.alternative;
854 return u.alternative;
858 return u.cache_invalidator;
862 return u.cache_invalidator;
866 return u.delete_rows;
870 return u.delete_rows;
874 return u.update_rows;
878 return u.update_rows;
1285static_assert(std::is_trivially_destructible<AccessPath>::value,
1286 "AccessPath must be trivially destructible, as it is allocated "
1287 "on the MEM_ROOT and not wrapped in unique_ptr_destroy_only"
1288 "(because multiple candidates during planning could point to "
1289 "the same access paths, and refcounting would be expensive)");
1291 "We are creating a lot of access paths in the join "
1292 "optimizer, so be sure not to bloat it without noticing. "
1293 "(96 bytes for the base, 48 bytes for the variant.)");
1309 bool count_examined_rows) {
1312 path->count_examined_rows = count_examined_rows;
1319 bool count_examined_rows) {
1322 path->count_examined_rows = count_examined_rows;
1324 path->index_scan().idx = idx;
1325 path->index_scan().use_order = use_order;
1332 bool count_examined_rows) {
1335 path->count_examined_rows = count_examined_rows;
1338 path->ref().use_order = use_order;
1345 bool count_examined_rows) {
1348 path->count_examined_rows = count_examined_rows;
1350 path->ref_or_null().ref =
ref;
1351 path->ref_or_null().use_order = use_order;
1356 bool count_examined_rows) {
1359 path->count_examined_rows = count_examined_rows;
1368 bool count_examined_rows) {
1371 path->count_examined_rows = count_examined_rows;
1373 path->pushed_join_ref().ref =
ref;
1374 path->pushed_join_ref().use_order = use_order;
1375 path->pushed_join_ref().is_unique = is_unique;
1382 bool use_order,
bool use_limit,
1383 bool count_examined_rows) {
1386 path->count_examined_rows = count_examined_rows;
1388 path->full_text_search().ref =
ref;
1389 path->full_text_search().use_order = use_order;
1390 path->full_text_search().use_limit = use_limit;
1391 path->full_text_search().ft_func = ft_func;
1397 bool count_examined_rows) {
1400 path->count_examined_rows = count_examined_rows;
1401 path->set_num_output_rows(1.0);
1402 path->set_cost(0.0);
1403 path->set_init_cost(0.0);
1404 path->set_init_once_cost(0.0);
1406 path->const_table().ref =
ref;
1416 path->mrr().mrr_flags = mrr_flags;
1419 path->mrr().bka_path =
nullptr;
1425 bool count_examined_rows) {
1428 path->count_examined_rows = count_examined_rows;
1437 path->count_examined_rows = count_examined_rows;
1438 path->dynamic_index_range_scan().table =
table;
1439 path->dynamic_index_range_scan().qep_tab = qep_tab;
1448 path->materialized_table_function().table =
table;
1449 path->materialized_table_function().table_function = table_function;
1450 path->materialized_table_function().table_path = table_path;
1465 KEY *
key,
size_t key_len) {
1468 path->nested_loop_semijoin_with_duplicate_removal().outer = outer;
1469 path->nested_loop_semijoin_with_duplicate_removal().inner = inner;
1470 path->nested_loop_semijoin_with_duplicate_removal().table =
table;
1471 path->nested_loop_semijoin_with_duplicate_removal().key =
key;
1472 path->nested_loop_semijoin_with_duplicate_removal().key_len = key_len;
1480 path->filter().child = child;
1481 path->filter().condition = condition;
1482 path->filter().materialize_subqueries =
false;
1483 path->has_group_skip_scan = child->has_group_skip_scan;
1490 ORDER *order,
bool count_examined_rows);
1496 path->aggregate().child = child;
1497 path->aggregate().olap = olap;
1498 path->has_group_skip_scan = child->has_group_skip_scan;
1507 path->temptable_aggregate().subquery_path = subquery_path;
1508 path->temptable_aggregate().temp_table_param = temp_table_param;
1509 path->temptable_aggregate().table =
table;
1510 path->temptable_aggregate().table_path = table_path;
1511 path->temptable_aggregate().ref_slice = ref_slice;
1517 bool count_all_rows,
1518 bool reject_multiple_rows,
1519 ha_rows *send_records_override) {
1523 path->immediate_update_delete_table = child->immediate_update_delete_table;
1524 path->limit_offset().child = child;
1525 path->limit_offset().limit = limit;
1526 path->limit_offset().offset = offset;
1527 path->limit_offset().count_all_rows = count_all_rows;
1528 path->limit_offset().reject_multiple_rows = reject_multiple_rows;
1529 path->limit_offset().send_records_override = send_records_override;
1530 path->ordering_state = child->ordering_state;
1531 path->has_group_skip_scan = child->has_group_skip_scan;
1537 bool count_examined_rows) {
1540 path->count_examined_rows = count_examined_rows;
1541 path->set_num_output_rows(1.0);
1542 path->set_cost(0.0);
1543 path->set_init_cost(0.0);
1544 path->set_init_once_cost(0.0);
1549 const char *cause) {
1552 path->zero_rows().child = child;
1553 path->zero_rows().cause = cause;
1554 path->set_num_output_rows(0.0);
1555 path->set_cost(0.0);
1556 path->set_init_cost(0.0);
1557 path->set_init_once_cost(0.0);
1558 path->num_output_rows_before_filter = 0.0;
1559 path->set_cost_before_filter(0.0);
1568 const char *cause) {
1571 path->zero_rows_aggregated().cause = cause;
1572 path->set_num_output_rows(1.0);
1573 path->set_cost(0.0);
1574 path->set_init_cost(0.0);
1584 path->stream().child = child;
1586 path->stream().temp_table_param = temp_table_param;
1588 path->stream().ref_slice = ref_slice;
1590 path->stream().provide_rowid =
false;
1591 path->has_group_skip_scan = child->has_group_skip_scan;
1599 assert(
path !=
nullptr);
1615 int ref_slice,
bool rematerialize,
ha_rows limit_rows,
1616 bool reject_multiple_rows) {
1620 if (rematerialize) {
1648 path->materialize().table_path = table_path;
1649 path->materialize().param = param;
1651 if (rematerialize) {
1664 path->materialize_information_schema_table().table_path = table_path;
1665 path->materialize_information_schema_table().table_list = table_list;
1666 path->materialize_information_schema_table().condition = condition;
1688 path->append().children = children;
1689 double num_output_rows = 0.0;
1692 path->set_init_cost(
AddCost(
path->init_cost(), child.path->init_cost()));
1693 path->set_init_once_cost(
path->init_once_cost() +
1694 child.path->init_once_cost());
1695 num_output_rows += child.path->num_output_rows();
1697 path->set_num_output_rows(num_output_rows);
1704 int ref_slice,
bool needs_buffering) {
1707 path->window().child = child;
1708 path->window().window = window;
1709 path->window().temp_table =
nullptr;
1710 path->window().temp_table_param = temp_table_param;
1711 path->window().ref_slice = ref_slice;
1712 path->window().needs_buffering = needs_buffering;
1713 path->set_num_output_rows(child->num_output_rows());
1721 path->weedout().child = child;
1722 path->weedout().weedout_table = weedout_table;
1723 path->weedout().tables_to_get_rowid_for =
1730 int group_items_size) {
1733 path->remove_duplicates().child = child;
1734 path->remove_duplicates().group_items = group_items;
1735 path->remove_duplicates().group_items_size = group_items_size;
1736 path->has_group_skip_scan = child->has_group_skip_scan;
1742 unsigned loosescan_key_len) {
1745 path->remove_duplicates_on_index().child = child;
1746 path->remove_duplicates_on_index().table =
table;
1747 path->remove_duplicates_on_index().key =
key;
1748 path->remove_duplicates_on_index().loosescan_key_len = loosescan_key_len;
1749 path->has_group_skip_scan = child->has_group_skip_scan;
1758 path->alternative().table_scan_path = table_scan_path;
1759 path->alternative().child = child;
1760 path->alternative().used_ref = used_ref;
1768 path->cache_invalidator().child = child;
1769 path->cache_invalidator().name =
name;
1789 bool eligible_for_batch_mode);
1797 eligible_for_batch_mode);
1801 const POSITION *pos,
bool is_after_filter,
1848 unsigned num_where_predicates);
1856 int num_where_predicates);
1862 unsigned num_where_predicates);
1884 const std::vector<HashJoinCondition> &equijoin_conditions,
constexpr double kUnknownCost
To indicate that a cost estimate is not yet made.
Definition: access_path.h:188
AccessPath * NewStreamingAccessPath(THD *thd, AccessPath *child, JOIN *join, Temp_table_param *temp_table_param, TABLE *table, int ref_slice)
Definition: access_path.h:1578
AccessPath * NewRemoveDuplicatesAccessPath(THD *thd, AccessPath *child, Item **group_items, int group_items_size)
Definition: access_path.h:1728
AccessPath * NewInvalidatorAccessPath(THD *thd, AccessPath *child, const char *name)
Definition: access_path.h:1764
AccessPath * NewRefAccessPath(THD *thd, TABLE *table, Index_lookup *ref, bool use_order, bool reverse, bool count_examined_rows)
Definition: access_path.h:1330
AccessPath * NewDeleteRowsAccessPath(THD *thd, AccessPath *child, table_map delete_tables, table_map immediate_tables)
Definition: access_path.cc:121
void CopyBasicProperties(const AccessPath &from, AccessPath *to)
Definition: access_path.h:1295
void ExpandSingleFilterAccessPath(THD *thd, AccessPath *path, const JOIN *join, const Mem_root_array< Predicate > &predicates, unsigned num_where_predicates)
Like ExpandFilterAccessPaths(), but expands only the single access path at “path”.
Definition: access_path.cc:1489
AccessPath * NewFullTextSearchAccessPath(THD *thd, TABLE *table, Index_lookup *ref, Item_func_match *ft_func, bool use_order, bool use_limit, bool count_examined_rows)
Definition: access_path.h:1379
AccessPath * NewTemptableAggregateAccessPath(THD *thd, AccessPath *subquery_path, Temp_table_param *temp_table_param, TABLE *table, AccessPath *table_path, int ref_slice)
Definition: access_path.h:1502
table_map GetHashJoinTables(AccessPath *path)
Returns the tables that are part of a hash join.
Definition: access_path.cc:1616
AccessPath * NewDynamicIndexRangeScanAccessPath(THD *thd, TABLE *table, QEP_TAB *qep_tab, bool count_examined_rows)
Definition: access_path.h:1433
AccessPath * NewZeroRowsAggregatedAccessPath(THD *thd, const char *cause)
Definition: access_path.h:1567
AccessPath * NewAlternativeAccessPath(THD *thd, AccessPath *child, AccessPath *table_scan_path, Index_lookup *used_ref)
Definition: access_path.h:1753
AccessPath * NewUpdateRowsAccessPath(THD *thd, AccessPath *child, table_map delete_tables, table_map immediate_tables)
Definition: access_path.cc:133
AccessPath * NewMRRAccessPath(THD *thd, TABLE *table, Index_lookup *ref, int mrr_flags)
Definition: access_path.h:1410
table_map GetUsedTableMap(const AccessPath *path, bool include_pruned_tables)
Returns a map of all tables read when path or any of its children are executed.
Definition: access_path.cc:269
AccessPath * NewAppendAccessPath(THD *thd, Mem_root_array< AppendPathParameters > *children)
Definition: access_path.h:1684
AccessPath * NewNestedLoopSemiJoinWithDuplicateRemovalAccessPath(THD *thd, AccessPath *outer, AccessPath *inner, const TABLE *table, KEY *key, size_t key_len)
Definition: access_path.h:1463
AccessPath * NewRemoveDuplicatesOnIndexAccessPath(THD *thd, AccessPath *child, TABLE *table, KEY *key, unsigned loosescan_key_len)
Definition: access_path.h:1740
AccessPath * NewFakeSingleRowAccessPath(THD *thd, bool count_examined_rows)
Definition: access_path.h:1536
AccessPath * NewTableValueConstructorAccessPath(const THD *thd, const JOIN *join)
Definition: access_path.cc:165
Item * ConditionFromFilterPredicates(const Mem_root_array< Predicate > &predicates, OverflowBitset mask, int num_where_predicates)
Extracts the Item expression from the given “filter_predicates” corresponding to the given “mask”.
Definition: access_path.cc:1478
AccessPath * NewFilterAccessPath(THD *thd, AccessPath *child, Item *condition)
Definition: access_path.h:1476
constexpr double kUnknownRowCount
To indicate that a row estimate is not yet made.
Definition: access_path.h:183
AccessPath * NewSortAccessPath(THD *thd, AccessPath *child, Filesort *filesort, ORDER *order, bool count_examined_rows)
Definition: access_path.cc:86
AccessPath * NewMaterializedTableFunctionAccessPath(THD *thd, TABLE *table, Table_function *table_function, AccessPath *table_path)
Definition: access_path.h:1443
AccessPath * NewMaterializeAccessPath(THD *thd, Mem_root_array< MaterializePathParameters::Operand > operands, Mem_root_array< const AccessPath * > *invalidators, TABLE *table, AccessPath *table_path, Common_table_expr *cte, Query_expression *unit, int ref_slice, bool rematerialize, ha_rows limit_rows, bool reject_multiple_rows)
Definition: access_path.h:1611
const Mem_root_array< Item * > * GetExtraHashJoinConditions(MEM_ROOT *mem_root, bool using_hypergraph_optimizer, const std::vector< HashJoinCondition > &equijoin_conditions, const Mem_root_array< Item * > &other_conditions)
Get the conditions to put into the extra conditions of the HashJoinIterator.
Mem_root_array< TABLE * > CollectTables(THD *thd, AccessPath *root_path)
Find the list of all tables used by this root, stopping at materializations.
Definition: access_path.cc:300
AccessPath * NewTableScanAccessPath(THD *thd, TABLE *table, bool count_examined_rows)
Definition: access_path.h:1308
AccessPath * NewAggregateAccessPath(THD *thd, AccessPath *child, olap_type olap)
Definition: access_path.h:1492
void ExpandFilterAccessPaths(THD *thd, AccessPath *path, const JOIN *join, const Mem_root_array< Predicate > &predicates, unsigned num_where_predicates)
For each access path in the (sub)tree rooted at “path”, expand any use of “filter_predicates” into ne...
Definition: access_path.cc:1604
double AddCost(double c1, double c2)
Add path costs c1 and c2, but handle kUnknownCost correctly.
Definition: access_path.h:1671
AccessPath * NewMaterializeInformationSchemaTableAccessPath(THD *thd, AccessPath *table_path, Table_ref *table_list, Item *condition)
Definition: access_path.h:1660
void FindTablesToGetRowidFor(AccessPath *path)
Modifies "path" and the paths below it so that they provide row IDs for all tables.
Definition: access_path.cc:1334
TABLE * GetBasicTable(const AccessPath *path)
Return the TABLE* referred from 'path' if it is a basic access path, else a nullptr is returned.
Definition: access_path.cc:214
AccessPath * NewRefOrNullAccessPath(THD *thd, TABLE *table, Index_lookup *ref, bool use_order, bool count_examined_rows)
Definition: access_path.h:1343
AccessPath * NewLimitOffsetAccessPath(THD *thd, AccessPath *child, ha_rows limit, ha_rows offset, bool count_all_rows, bool reject_multiple_rows, ha_rows *send_records_override)
Definition: access_path.h:1515
AccessPath * NewEQRefAccessPath(THD *thd, TABLE *table, Index_lookup *ref, bool count_examined_rows)
Definition: access_path.h:1355
AccessPath * NewWindowAccessPath(THD *thd, AccessPath *child, Window *window, Temp_table_param *temp_table_param, int ref_slice, bool needs_buffering)
Definition: access_path.h:1701
AccessPath * NewFollowTailAccessPath(THD *thd, TABLE *table, bool count_examined_rows)
Definition: access_path.h:1424
AccessPath * NewConstTableAccessPath(THD *thd, TABLE *table, Index_lookup *ref, bool count_examined_rows)
Definition: access_path.h:1395
unique_ptr_destroy_only< RowIterator > CreateIteratorFromAccessPath(THD *thd, MEM_ROOT *mem_root, AccessPath *path, JOIN *join, bool eligible_for_batch_mode)
Definition: access_path.cc:485
AccessPath * NewWeedoutAccessPath(THD *thd, AccessPath *child, SJ_TMP_TABLE *weedout_table)
Definition: access_path.h:1717
AccessPath * NewPushedJoinRefAccessPath(THD *thd, TABLE *table, Index_lookup *ref, bool use_order, bool is_unique, bool count_examined_rows)
Definition: access_path.h:1365
AccessPath * NewZeroRowsAccessPath(THD *thd, AccessPath *child, const char *cause)
Definition: access_path.h:1548
AccessPath * NewUnqualifiedCountAccessPath(THD *thd)
Definition: access_path.h:1454
AccessPath * NewIndexScanAccessPath(THD *thd, TABLE *table, int idx, bool use_order, bool reverse, bool count_examined_rows)
Definition: access_path.h:1317
Mem_root_array< MaterializePathParameters::Operand > SingleMaterializeQueryBlock(THD *thd, AccessPath *path, int select_number, JOIN *join, bool copy_items, Temp_table_param *temp_table_param)
Definition: access_path.h:1596
After parsing, a Common Table Expression is accessed through a Table_ref.
Definition: table.h:4390
API for getting cost estimates for server operations that are not directly related to a table object.
Definition: opt_costmodel.h:53
Sorting related info.
Definition: filesort.h:51
A class that represents a join condition in a hash join.
Definition: item_cmpfunc.h:86
Definition: item_func.h:3455
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:933
Definition: sql_optimizer.h:132
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:425
Definition: overflow_bitset.h:77
Definition: sql_executor.h:253
Definition: range_optimizer.h:68
This class represents a query expression (one query block or several query blocks combined with UNION...
Definition: sql_lex.h:624
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:81
Definition: sql_executor.h:94
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
MEM_ROOT * mem_root
Definition: sql_lexer_thd.h:39
Class representing a table function.
Definition: table_function.h:52
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:94
Represents the (explicit) window of a SQL 2003 section 7.11 <window clause>, or the implicit (inlined...
Definition: window.h:104
static MEM_ROOT mem_root
Definition: client_plugin.cc:113
void EstimateLimitOffsetCost(AccessPath *path)
Estimate the costs and row count for a LIMIT_OFFSET AccessPath.
Definition: cost_model.cc:932
bool filesort(THD *thd, Filesort *filesort, RowIterator *source_iterator, table_map tables_to_get_rowid_for, ha_rows num_rows_estimate, Filesort_info *fs_info, Sort_result *sort_result, ha_rows *found_rows)
Sort a table.
Definition: filesort.cc:366
void SetCostOnTableAccessPath(const Cost_model_server &cost_model, const POSITION *pos, bool is_after_filter, AccessPath *path)
Definition: sql_executor.cc:1865
std::bitset< kMaxSupportedFDs > FunctionalDependencySet
Definition: interesting_orders_defs.h:62
JoinType
Definition: join_type.h:27
static mi_bit_type mask[]
Definition: mi_packrec.cc:140
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:476
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1140
#define HA_POS_ERROR
Definition: my_base.h:1142
uint64_t table_map
Definition: my_table_map.h:29
static char * path
Definition: mysqldump.cc:148
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
PT & ref(PT *tp)
Definition: tablespace_impl.cc:358
uint64_t NodeMap
Since our graphs can never have more than 61 tables, node sets and edge lists are implemented using 6...
Definition: node_map.h:39
RangeReverse< Range > reverse(Range &x)
Iterate over a range in reverse.
Definition: utilities.h:131
std::string join(Container cont, const std::string &delim)
join elements of an container into a string separated by a delimiter.
Definition: string.h:150
int delete_tables(PFS_engine_table_share_proxy **, unsigned int) noexcept
Definition: pfs_plugin_table_v1_all_empty.cc:38
olap_type
Definition: olap.h:30
OverflowBitset is a fixed-size (once allocated) bitmap that is optimized for the common case of few e...
required string key
Definition: replication_asynchronous_connection_failover.proto:59
case opt name
Definition: sslopt-case.h:32
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:212
struct AccessPath::@60::@67 pushed_join_ref
auto & weedout()
Definition: access_path.h:824
struct AccessPath::@60::@75 rowid_union
auto & filter()
Definition: access_path.h:744
bool count_all_rows
Definition: access_path.h:1204
AccessPath * bka_path
Definition: access_path.h:974
auto & ref_or_null()
Definition: access_path.h:552
auto & materialized_table_function()
Definition: access_path.h:664
AccessPath * cpk_child
Definition: access_path.h:1035
auto & rowid_union()
Definition: access_path.h:632
hypergraph::NodeMap parameter_tables
If nonzero, a bitmap of other tables whose joined-in rows must already be loaded when rows from this ...
Definition: access_path.h:508
const auto & bka_join() const
Definition: access_path.h:724
TABLE * temp_table
Definition: access_path.h:1241
OverflowBitset equijoin_predicates
Definition: access_path.h:1145
Item ** group_items
Definition: access_path.h:1253
struct AccessPath::@60::@79 materialized_table_function
double rescan_cost() const
Return the cost of scanning the given path for the second time (or later) in the given query block.
Definition: access_path.h:419
auto & materialize()
Definition: access_path.h:792
const auto & temptable_aggregate() const
Definition: access_path.h:772
OverflowBitset & subsumed_sargable_join_predicates()
Similar to applied_sargable_join_predicates, bitmap of sargable join predicates that have been applie...
Definition: access_path.h:480
auto & index_scan()
Definition: access_path.h:528
const auto & delete_rows() const
Definition: access_path.h:868
const auto & filter() const
Definition: access_path.h:748
const auto & index_distance_scan() const
Definition: access_path.h:540
auto & delete_rows()
Definition: access_path.h:864
struct AccessPath::@60::@74 rowid_intersection
bool reuse_handler
Definition: access_path.h:1012
struct AccessPath::@60::@90 sort
KEY_PART * used_key_part
Definition: access_path.h:986
double m_init_cost
Expected cost to initialize this access path; ie., cost to read k out of N rows would be init_cost + ...
Definition: access_path.h:899
olap_type olap
Definition: access_path.h:1191
OverflowBitset & applied_sargable_join_predicates()
Bitmap of sargable join predicates that have already been applied in this access path by means of an ...
Definition: access_path.h:460
Item * condition
Definition: access_path.h:1163
const auto & index_merge() const
Definition: access_path.h:620
const auto & update_rows() const
Definition: access_path.h:876
enum AccessPath::Type type
auto & alternative()
Definition: access_path.h:848
auto & pushed_join_ref()
Definition: access_path.h:568
struct AccessPath::@60::@95 materialize
void set_cost(double val)
Definition: access_path.h:393
AccessPath * outer
Definition: access_path.h:1119
struct AccessPath::@60::@104 delete_rows
auto & index_skip_scan()
Definition: access_path.h:640
bool rewrite_semi_to_inner
Definition: access_path.h:1123
const auto & zero_rows_aggregated() const
Definition: access_path.h:708
auto & group_index_skip_scan()
Definition: access_path.h:648
const auto & eq_ref() const
Definition: access_path.h:564
int group_items_size
Definition: access_path.h:1254
bool use_order
Definition: access_path.h:930
bool pfs_batch_mode
Definition: access_path.h:1137
auto & temptable_aggregate()
Definition: access_path.h:768
AccessPath()
Definition: access_path.h:218
GroupIndexSkipScanParameters * param
Definition: access_path.h:1079
auto & rowid_intersection()
Definition: access_path.h:624
struct AccessPath::@60::@89 filter
double init_cost() const
Definition: access_path.h:387
bool materialize_subqueries
Definition: access_path.h:1173
AccessPath * child
Definition: access_path.h:1107
bool allow_spill_to_disk
Definition: access_path.h:1121
struct AccessPath::@60::@85 hash_join
struct AccessPath::@60::@61 table_scan
Index_lookup * used_ref
Definition: access_path.h:1267
auto & mrr()
Definition: access_path.h:592
const auto & index_scan() const
Definition: access_path.h:532
const auto & fake_single_row() const
Definition: access_path.h:692
struct AccessPath::@60::@99 weedout
bool reject_multiple_rows
Definition: access_path.h:1205
bool allow_clustered_primary_key_scan
Definition: access_path.h:1027
const char * name
Definition: access_path.h:1271
bool use_limit
Definition: access_path.h:964
Window * window
Definition: access_path.h:1240
table_map tables_to_get_rowid_for
Definition: access_path.h:1124
auto & materialize_information_schema_table()
Definition: access_path.h:800
auto & bka_join()
Definition: access_path.h:720
struct AccessPath::@60::@83 zero_rows
const auto & follow_tail() const
Definition: access_path.h:604
SJ_TMP_TABLE * weedout_table
Definition: access_path.h:1248
bool has_group_skip_scan
Whether this access path contains a GROUP_INDEX_SKIP_SCAN.
Definition: access_path.h:322
Index_lookup * ref
Definition: access_path.h:941
const auto & window() const
Definition: access_path.h:820
void set_init_once_cost(double val)
Definition: access_path.h:403
const auto & materialized_table_function() const
Definition: access_path.h:668
auto & unqualified_count()
Definition: access_path.h:672
bool keep_current_rowid
Definition: access_path.h:976
bool using_extended_key_parts
Definition: access_path.h:1022
struct AccessPath::@60::@66 eq_ref
auto & nested_loop_join()
Definition: access_path.h:728
const auto & full_text_search() const
Definition: access_path.h:580
struct AccessPath::@60::@92 temptable_aggregate
struct AccessPath::@60::@97 append
struct AccessPath::@60::@101 remove_duplicates_on_index
bool can_be_used_for_ror
Definition: access_path.h:1002
float rec_per_key
Definition: access_path.h:1130
Safety safe_for_rowid
Whether it is safe to get row IDs (for sorting) from this access path.
Definition: access_path.h:313
JOIN * join
Definition: access_path.h:1212
unsigned index
Definition: access_path.h:998
unsigned mrr_buf_size
Definition: access_path.h:994
auto & remove_duplicates()
Definition: access_path.h:832
struct AccessPath::@60::@78 dynamic_index_range_scan
struct AccessPath::@60::@93 limit_offset
RowIterator * iterator
If an iterator has been instantiated for this access path, points to the iterator.
Definition: access_path.h:383
const auto & stream() const
Definition: access_path.h:788
const auto & remove_duplicates() const
Definition: access_path.h:836
auto & window()
Definition: access_path.h:816
bool need_rows_in_rowid_order
Definition: access_path.h:1006
Table_ref * table_list
Definition: access_path.h:1232
const auto & unqualified_count() const
Definition: access_path.h:676
void * secondary_engine_data
Auxiliary data used by a secondary storage engine while processing the access path during optimizatio...
Definition: access_path.h:517
struct AccessPath::@60::@84 zero_rows_aggregated
void set_init_cost(double val)
Definition: access_path.h:398
void set_num_output_rows(double val)
Definition: access_path.h:883
bool is_covering
Definition: access_path.h:1055
const auto & mrr() const
Definition: access_path.h:596
void set_cost_before_filter(double val)
Definition: access_path.h:408
struct AccessPath::@60::@102 alternative
bool remove_duplicates
Definition: access_path.h:1185
table_map tables_to_update
Definition: access_path.h:1280
const auto & table_value_constructor() const
Definition: access_path.h:684
KEY * key
Definition: access_path.h:1157
struct AccessPath::@60::@65 ref_or_null
auto & table_value_constructor()
Definition: access_path.h:680
auto & stream()
Definition: access_path.h:784
size_t key_len
Definition: access_path.h:1158
const OverflowBitset & subsumed_sargable_join_predicates() const
Definition: access_path.h:483
const auto & zero_rows() const
Definition: access_path.h:700
const auto & append() const
Definition: access_path.h:812
ha_rows offset
Definition: access_path.h:1203
int idx
Definition: access_path.h:929
auto & hash_join()
Definition: access_path.h:712
auto & cache_invalidator()
Definition: access_path.h:856
bool force_sort_rowids
Definition: access_path.h:1187
unsigned num_used_key_parts
Definition: access_path.h:999
unsigned num_ranges
Definition: access_path.h:991
ORDER * order
Definition: access_path.h:1183
auto & sort()
Definition: access_path.h:752
auto & fake_single_row()
Definition: access_path.h:688
struct AccessPath::@60::@81 table_value_constructor
ha_rows limit
Definition: access_path.h:1184
struct AccessPath::@60::@73 index_merge
struct AccessPath::@60::@76 index_skip_scan
auto & follow_tail()
Definition: access_path.h:600
double m_num_output_rows
Expected number of output rows.
Definition: access_path.h:887
const JoinPredicate * join_predicate
Definition: access_path.h:1120
struct AccessPath::@60::@72 index_range_scan
const auto & const_table() const
Definition: access_path.h:588
struct AccessPath::@60::@69 const_table
const auto & dynamic_index_range_scan() const
Definition: access_path.h:660
const auto & table_scan() const
Definition: access_path.h:524
unsigned mrr_flags
Definition: access_path.h:993
int ref_slice
Definition: access_path.h:1198
OverflowBitset filter_predicates
Bitmap of WHERE predicates that we are including on this access path, referring to the “predicates” a...
Definition: access_path.h:444
bool can_be_used_for_imerge
Definition: access_path.h:1009
bool forced_by_hint
Definition: access_path.h:1026
struct AccessPath::@60::@82 fake_single_row
auto & limit_offset()
Definition: access_path.h:776
AccessPath * inner
Definition: access_path.h:1119
QUICK_RANGE * range
Definition: access_path.h:936
bool provide_rowid
Definition: access_path.h:1215
const auto & index_range_scan() const
Definition: access_path.h:612
const auto & ref() const
Definition: access_path.h:548
bool forced_by_dbug
Whether this access path is forced preferred over all others by means of a SET DEBUG force_subplan_0x...
Definition: access_path.h:327
Item_func_match * ft_func
Definition: access_path.h:965
struct AccessPath::@60::@96 materialize_information_schema_table
ha_rows * send_records_override
Definition: access_path.h:1208
struct AccessPath::@60::@94 stream
auto & table_scan()
Definition: access_path.h:520
const auto & hash_join() const
Definition: access_path.h:716
QEP_TAB * qep_tab
Definition: access_path.h:1083
Table_function * table_function
Definition: access_path.h:1087
auto & zero_rows_aggregated()
Definition: access_path.h:704
const auto & sort() const
Definition: access_path.h:756
bool unwrap_rollup
Definition: access_path.h:1186
Type
Definition: access_path.h:228
@ FOLLOW_TAIL
Definition: access_path.h:242
@ FILTER
Definition: access_path.h:266
@ PUSHED_JOIN_REF
Definition: access_path.h:238
@ ZERO_ROWS_AGGREGATED
Definition: access_path.h:255
@ UPDATE_ROWS
Definition: access_path.h:284
@ AGGREGATE
Definition: access_path.h:268
@ BKA_JOIN
Definition: access_path.h:262
@ ZERO_ROWS
Definition: access_path.h:254
@ CONST_TABLE
Definition: access_path.h:240
@ GROUP_INDEX_SKIP_SCAN
Definition: access_path.h:248
@ INDEX_RANGE_SCAN
Definition: access_path.h:243
@ UNQUALIFIED_COUNT
Definition: access_path.h:257
@ EQ_REF
Definition: access_path.h:237
@ FAKE_SINGLE_ROW
Definition: access_path.h:253
@ MATERIALIZE_INFORMATION_SCHEMA_TABLE
Definition: access_path.h:273
@ WINDOW
Definition: access_path.h:275
@ REF_OR_NULL
Definition: access_path.h:236
@ MATERIALIZE
Definition: access_path.h:272
@ NESTED_LOOP_SEMIJOIN_WITH_DUPLICATE_REMOVAL
Definition: access_path.h:261
@ ROWID_UNION
Definition: access_path.h:246
@ INDEX_SKIP_SCAN
Definition: access_path.h:247
@ MRR
Definition: access_path.h:241
@ CACHE_INVALIDATOR
Definition: access_path.h:280
@ INDEX_SCAN
Definition: access_path.h:233
@ TABLE_VALUE_CONSTRUCTOR
Definition: access_path.h:252
@ WEEDOUT
Definition: access_path.h:276
@ MATERIALIZED_TABLE_FUNCTION
Definition: access_path.h:256
@ REMOVE_DUPLICATES_ON_INDEX
Definition: access_path.h:278
@ TABLE_SCAN
Definition: access_path.h:232
@ REF
Definition: access_path.h:235
@ TEMPTABLE_AGGREGATE
Definition: access_path.h:269
@ LIMIT_OFFSET
Definition: access_path.h:270
@ APPEND
Definition: access_path.h:274
@ NESTED_LOOP_JOIN
Definition: access_path.h:260
@ INDEX_MERGE
Definition: access_path.h:244
@ FULL_TEXT_SEARCH
Definition: access_path.h:239
@ ALTERNATIVE
Definition: access_path.h:279
@ STREAM
Definition: access_path.h:271
@ REMOVE_DUPLICATES
Definition: access_path.h:277
@ ROWID_INTERSECTION
Definition: access_path.h:245
@ DYNAMIC_INDEX_RANGE_SCAN
Definition: access_path.h:249
@ DELETE_ROWS
Definition: access_path.h:283
@ SORT
Definition: access_path.h:267
@ INDEX_DISTANCE_SCAN
Definition: access_path.h:234
@ HASH_JOIN
Definition: access_path.h:263
bool retrieve_full_rows
Definition: access_path.h:1038
struct AccessPath::@60::@70 mrr
double m_init_once_cost
Of init_cost, how much of the initialization needs only to be done once per query block.
Definition: access_path.h:911
const auto & rowid_union() const
Definition: access_path.h:636
const TABLE * table
Definition: access_path.h:1156
const auto & index_skip_scan() const
Definition: access_path.h:644
auto & dynamic_index_range_scan()
Definition: access_path.h:656
const auto & pushed_join_ref() const
Definition: access_path.h:572
auto & remove_duplicates_on_index()
Definition: access_path.h:840
table_map immediate_tables
Definition: access_path.h:1276
double m_cost_before_filter
If no filter, identical to cost.
Definition: access_path.h:915
double cost() const
Definition: access_path.h:385
int mrr_flags
Definition: access_path.h:975
struct AccessPath::@60::@62 index_scan
auto & full_text_search()
Definition: access_path.h:576
const auto & materialize() const
Definition: access_path.h:796
int ordering_state
Which ordering the rows produced by this path follow, if any (see interesting_orders....
Definition: access_path.h:377
auto & eq_ref()
Definition: access_path.h:560
struct AccessPath::@60::@63 index_distance_scan
JoinType join_type
Definition: access_path.h:1128
struct AccessPath::@60::@77 group_index_skip_scan
const auto & limit_offset() const
Definition: access_path.h:780
MaterializePathParameters * param
Definition: access_path.h:1226
const char * cause
Definition: access_path.h:1110
auto & update_rows()
Definition: access_path.h:872
auto & index_merge()
Definition: access_path.h:616
auto & aggregate()
Definition: access_path.h:760
double m_cost
Expected cost to read all of this access path once.
Definition: access_path.h:890
struct AccessPath::@60::@91 aggregate
const auto & group_index_skip_scan() const
Definition: access_path.h:652
auto & zero_rows()
Definition: access_path.h:696
AccessPath * subquery_path
Definition: access_path.h:1194
Mem_root_array< AppendPathParameters > * children
Definition: access_path.h:1236
struct AccessPath::@60::@86 bka_join
const auto & nested_loop_join() const
Definition: access_path.h:732
bool already_expanded_predicates
Definition: access_path.h:1138
const auto & remove_duplicates_on_index() const
Definition: access_path.h:844
Temp_table_param * temp_table_param
Definition: access_path.h:1195
auto & nested_loop_semijoin_with_duplicate_removal()
Definition: access_path.h:736
bool reverse
Definition: access_path.h:931
AccessPath * table_scan_path
Definition: access_path.h:1263
struct AccessPath::@60::@88 nested_loop_semijoin_with_duplicate_removal
const auto & materialize_information_schema_table() const
Definition: access_path.h:804
double subquery_cost
The total cost of executing the queries that we materialize.
Definition: access_path.h:1228
bool geometry
Definition: access_path.h:1015
bool count_examined_rows
Whether this access path counts as one that scans a base table, and thus should be counted towards ex...
Definition: access_path.h:319
unsigned loosescan_key_len
Definition: access_path.h:1260
auto & index_distance_scan()
Definition: access_path.h:536
auto & ref()
Definition: access_path.h:544
table_map tables_to_delete_from
Definition: access_path.h:1275
struct AccessPath::@60::@87 nested_loop_join
double init_once_cost() const
Definition: access_path.h:389
IndexSkipScanParameters * param
Definition: access_path.h:1070
const OverflowBitset & applied_sargable_join_predicates() const
Definition: access_path.h:463
Mem_root_array< AccessPath * > * children
Definition: access_path.h:1028
struct AccessPath::@60::@80 unqualified_count
OverflowBitset delayed_predicates
Bitmap of WHERE predicates that touch tables we have joined in, but that we could not apply yet (for ...
Definition: access_path.h:472
AccessPath * table_path
Definition: access_path.h:1088
const auto & aggregate() const
Definition: access_path.h:764
struct AccessPath::@60::@103 cache_invalidator
TABLE * table
Definition: access_path.h:925
auto & append()
Definition: access_path.h:808
double cost_before_filter() const
Definition: access_path.h:391
const auto & weedout() const
Definition: access_path.h:828
const auto & cache_invalidator() const
Definition: access_path.h:860
bool needs_buffering
Definition: access_path.h:1244
int8_t immediate_update_delete_table
For UPDATE and DELETE statements: The node index of a table which can be updated or deleted from imme...
Definition: access_path.h:371
QUICK_RANGE ** ranges
Definition: access_path.h:990
struct AccessPath::@60::@68 full_text_search
bool is_unique
Definition: access_path.h:958
const auto & alternative() const
Definition: access_path.h:852
Safety
A general enum to describe the safety of a given operation.
Definition: access_path.h:294
@ SAFE_IF_SCANNED_ONCE
The given operation is safe if this access path is scanned once, but not if it's scanned multiple tim...
Definition: access_path.h:303
@ UNSAFE
The given operation is unsafe on this access path, no matter how many or few times it's scanned.
Definition: access_path.h:309
@ SAFE
The given operation is always safe on this access path.
Definition: access_path.h:296
auto & const_table()
Definition: access_path.h:584
struct AccessPath::@60::@105 update_rows
unsigned mrr_length_per_rec
Definition: access_path.h:1129
const auto & rowid_intersection() const
Definition: access_path.h:628
Mem_root_array< Item_values_column * > * output_refs
Definition: access_path.h:1094
auto & index_range_scan()
Definition: access_path.h:608
double num_output_rows() const
Definition: access_path.h:881
double num_output_rows_before_filter
If no filter, identical to num_output_rows.
Definition: access_path.h:422
const auto & ref_or_null() const
Definition: access_path.h:556
struct AccessPath::@60::@71 follow_tail
Filesort * filesort
Definition: access_path.h:1177
bool store_rowids
Definition: access_path.h:1122
const auto & nested_loop_semijoin_with_duplicate_removal() const
Definition: access_path.h:740
Definition: access_path.h:177
JOIN * join
Definition: access_path.h:179
AccessPath * path
Definition: access_path.h:178
Definition: group_index_skip_scan_plan.h:44
Logically a part of AccessPath::index_skip_scan(), but is too large, so split out into its own struct...
Definition: index_skip_scan_plan.h:72
Structure used for index-based lookups.
Definition: sql_opt_exec_shared.h:66
A specification that two specific relational expressions (e.g., two tables, or a table and a join bet...
Definition: access_path.h:77
int semijoin_group_size
Definition: access_path.h:123
FunctionalDependencySet functional_dependencies
Definition: access_path.h:94
Mem_root_array< int > functional_dependencies_idx
Definition: access_path.h:99
RelationalExpression * expr
Definition: access_path.h:78
double selectivity
Definition: access_path.h:79
int ordering_idx_needed_for_semijoin_rewrite
Definition: access_path.h:117
Item ** semijoin_group
Definition: access_path.h:122
size_t estimated_bytes_per_row
Definition: access_path.h:83
Definition: range_optimizer.h:54
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
Definition: materialize_path_parameters.h:41
AccessPath * subquery_path
Definition: materialize_path_parameters.h:42
int select_number
Definition: materialize_path_parameters.h:43
JOIN * join
Definition: materialize_path_parameters.h:44
bool copy_items
Definition: materialize_path_parameters.h:46
Temp_table_param * temp_table_param
Definition: materialize_path_parameters.h:47
bool disable_deduplication_by_hash_field
Definition: materialize_path_parameters.h:45
Definition: materialize_path_parameters.h:39
bool rematerialize
True if rematerializing on every Init() call (e.g., because we have a dependency on a value from outs...
Definition: materialize_path_parameters.h:79
Mem_root_array< Operand > m_operands
Definition: materialize_path_parameters.h:57
Common_table_expr * cte
If materializing a CTE, points to it (see m_cte), otherwise nullptr.
Definition: materialize_path_parameters.h:64
bool reject_multiple_rows
True if this is the top level iterator for a materialized derived table transformed from a scalar sub...
Definition: materialize_path_parameters.h:98
ha_rows limit_rows
Used for when pushing LIMIT down to MaterializeIterator; this is more efficient than having a LimitOf...
Definition: materialize_path_parameters.h:91
TABLE * table
Handle to table to materialize into.
Definition: materialize_path_parameters.h:61
int ref_slice
Definition: materialize_path_parameters.h:73
Query_expression * unit
The query expression we are materializing.
Definition: materialize_path_parameters.h:67
Mem_root_array< const AccessPath * > * invalidators
Definition: materialize_path_parameters.h:58
A position of table within a join order.
Definition: sql_select.h:354
A filter of some sort that is not a join condition (those are stored in JoinPredicate objects).
Definition: access_path.h:131
hypergraph::NodeMap total_eligibility_set
Definition: access_path.h:144
bool was_join_condition
Definition: access_path.h:157
Mem_root_array< int > functional_dependencies_idx
Definition: access_path.h:169
FunctionalDependencySet functional_dependencies
Definition: access_path.h:168
int source_multiple_equality_idx
Definition: access_path.h:165
hypergraph::NodeMap used_nodes
Definition: access_path.h:135
Item * condition
Definition: access_path.h:132
double selectivity
Definition: access_path.h:146
Mem_root_array< ContainedSubquery > contained_subqueries
Definition: access_path.h:174
Represents an expression tree in the relational algebra of joins.
Definition: relational_expression.h:144