24#ifndef SQL_JOIN_OPTIMIZER_ACCESS_PATH_H
25#define SQL_JOIN_OPTIMIZER_ACCESS_PATH_H
211 double output_rows) {
212 assert(init_cost >= 0.0);
213 assert(total_cost >= init_cost);
214 assert(output_rows >= 0.0);
215 if (output_rows <= 1.0) {
218 return init_cost + (total_cost - init_cost) / output_rows;
416 assert(std::isfinite(val));
422 assert(std::isfinite(val));
428 assert(std::isfinite(val));
434 assert(std::isfinite(val));
573 return u.sample_scan;
577 return u.sample_scan;
589 return u.index_distance_scan;
593 return u.index_distance_scan;
605 return u.ref_or_null;
609 return u.ref_or_null;
621 return u.pushed_join_ref;
625 return u.pushed_join_ref;
629 return u.full_text_search;
633 return u.full_text_search;
637 return u.const_table;
641 return u.const_table;
653 return u.follow_tail;
657 return u.follow_tail;
661 return u.index_range_scan;
665 return u.index_range_scan;
669 return u.index_merge;
673 return u.index_merge;
677 return u.rowid_intersection;
681 return u.rowid_intersection;
685 return u.rowid_union;
689 return u.rowid_union;
693 return u.index_skip_scan;
697 return u.index_skip_scan;
701 return u.group_index_skip_scan;
705 return u.group_index_skip_scan;
709 return u.dynamic_index_range_scan;
713 return u.dynamic_index_range_scan;
717 return u.materialized_table_function;
721 return u.materialized_table_function;
725 return u.unqualified_count;
729 return u.unqualified_count;
733 return u.table_value_constructor;
737 return u.table_value_constructor;
741 return u.fake_single_row;
745 return u.fake_single_row;
757 return u.zero_rows_aggregated;
761 return u.zero_rows_aggregated;
781 return u.nested_loop_join;
785 return u.nested_loop_join;
789 return u.nested_loop_semijoin_with_duplicate_removal;
793 return u.nested_loop_semijoin_with_duplicate_removal;
821 return u.temptable_aggregate;
825 return u.temptable_aggregate;
829 return u.limit_offset;
833 return u.limit_offset;
845 return u.materialize;
849 return u.materialize;
853 return u.materialize_information_schema_table;
857 return u.materialize_information_schema_table;
885 return u.remove_duplicates;
889 return u.remove_duplicates;
893 return u.remove_duplicates_on_index;
897 return u.remove_duplicates_on_index;
901 return u.alternative;
905 return u.alternative;
909 return u.cache_invalidator;
913 return u.cache_invalidator;
917 return u.delete_rows;
921 return u.delete_rows;
925 return u.update_rows;
929 return u.update_rows;
935 assert(std::isfinite(val));
1326 const ItemSpan &group_items()
const {
1366 "AccessPath must be trivially destructible, as it is allocated "
1367 "on the MEM_ROOT and not wrapped in unique_ptr_destroy_only"
1368 "(because multiple candidates during planning could point to "
1369 "the same access paths, and refcounting would be expensive)");
1371 "We are creating a lot of access paths in the join "
1372 "optimizer, so be sure not to bloat it without noticing. "
1373 "(104 bytes for the base, 52 bytes for the variant.)");
1393 bool count_examined_rows) {
1396 path->count_examined_rows = count_examined_rows;
1402 double sampling_percentage,
1403 bool count_examined_rows) {
1406 path->count_examined_rows = count_examined_rows;
1408 path->sample_scan().sampling_percentage = sampling_percentage;
1414 bool count_examined_rows) {
1417 path->count_examined_rows = count_examined_rows;
1419 path->index_scan().idx = idx;
1420 path->index_scan().use_order = use_order;
1427 bool count_examined_rows) {
1430 path->count_examined_rows = count_examined_rows;
1433 path->ref().use_order = use_order;
1440 bool count_examined_rows) {
1443 path->count_examined_rows = count_examined_rows;
1445 path->ref_or_null().ref =
ref;
1446 path->ref_or_null().use_order = use_order;
1451 bool count_examined_rows) {
1454 path->count_examined_rows = count_examined_rows;
1463 bool count_examined_rows) {
1466 path->count_examined_rows = count_examined_rows;
1468 path->pushed_join_ref().ref =
ref;
1469 path->pushed_join_ref().use_order = use_order;
1470 path->pushed_join_ref().is_unique = is_unique;
1477 bool use_order,
bool use_limit,
1478 bool count_examined_rows) {
1481 path->count_examined_rows = count_examined_rows;
1483 path->full_text_search().ref =
ref;
1484 path->full_text_search().use_order = use_order;
1485 path->full_text_search().use_limit = use_limit;
1486 path->full_text_search().ft_func = ft_func;
1492 bool count_examined_rows) {
1495 path->count_examined_rows = count_examined_rows;
1496 path->set_num_output_rows(1.0);
1497 path->set_cost(0.0);
1498 path->set_init_cost(0.0);
1499 path->set_init_once_cost(0.0);
1501 path->const_table().ref =
ref;
1511 path->mrr().mrr_flags = mrr_flags;
1514 path->mrr().bka_path =
nullptr;
1520 bool count_examined_rows) {
1523 path->count_examined_rows = count_examined_rows;
1532 path->count_examined_rows = count_examined_rows;
1533 path->dynamic_index_range_scan().table =
table;
1534 path->dynamic_index_range_scan().qep_tab = qep_tab;
1543 path->materialized_table_function().table =
table;
1544 path->materialized_table_function().table_function = table_function;
1545 path->materialized_table_function().table_path = table_path;
1560 KEY *
key,
size_t key_len) {
1563 path->nested_loop_semijoin_with_duplicate_removal().outer = outer;
1564 path->nested_loop_semijoin_with_duplicate_removal().inner = inner;
1565 path->nested_loop_semijoin_with_duplicate_removal().table =
table;
1566 path->nested_loop_semijoin_with_duplicate_removal().key =
key;
1567 path->nested_loop_semijoin_with_duplicate_removal().key_len = key_len;
1568 path->has_group_skip_scan =
1577 path->filter().child = child;
1578 path->filter().condition = condition;
1579 path->filter().materialize_subqueries =
false;
1580 path->has_group_skip_scan = child->has_group_skip_scan;
1587 ORDER *order,
bool count_examined_rows);
1593 path->aggregate().child = child;
1594 path->aggregate().olap = olap;
1595 path->has_group_skip_scan = child->has_group_skip_scan;
1605 path->temptable_aggregate().subquery_path = subquery_path;
1606 path->temptable_aggregate().join =
join;
1607 path->temptable_aggregate().temp_table_param = temp_table_param;
1608 path->temptable_aggregate().table =
table;
1609 path->temptable_aggregate().table_path = table_path;
1610 path->temptable_aggregate().ref_slice = ref_slice;
1616 bool count_all_rows,
1617 bool reject_multiple_rows,
1618 ha_rows *send_records_override) {
1622 path->immediate_update_delete_table = child->immediate_update_delete_table;
1623 path->limit_offset().child = child;
1624 path->limit_offset().limit = limit;
1625 path->limit_offset().offset = offset;
1626 path->limit_offset().count_all_rows = count_all_rows;
1627 path->limit_offset().reject_multiple_rows = reject_multiple_rows;
1628 path->limit_offset().send_records_override = send_records_override;
1635 bool count_examined_rows) {
1638 path->count_examined_rows = count_examined_rows;
1639 path->set_num_output_rows(1.0);
1640 path->set_cost(0.0);
1641 path->set_init_cost(0.0);
1642 path->set_init_once_cost(0.0);
1647 const char *cause) {
1650 path->zero_rows().child = child;
1651 path->zero_rows().cause = cause;
1652 path->set_num_output_rows(0.0);
1653 path->set_cost(0.0);
1654 path->set_init_cost(0.0);
1655 path->set_init_once_cost(0.0);
1656 path->num_output_rows_before_filter = 0.0;
1657 path->set_cost_before_filter(0.0);
1666 const char *cause) {
1669 path->zero_rows_aggregated().cause = cause;
1670 path->set_num_output_rows(1.0);
1671 path->set_cost(0.0);
1672 path->set_init_cost(0.0);
1684 assert(
path !=
nullptr);
1700 int ref_slice,
bool rematerialize,
ha_rows limit_rows,
1701 bool reject_multiple_rows,
1707 if (rematerialize) {
1736 path->materialize().table_path = table_path;
1737 path->materialize().param = param;
1740 if (rematerialize) {
1753 path->materialize_information_schema_table().table_path = table_path;
1754 path->materialize_information_schema_table().table_list = table_list;
1755 path->materialize_information_schema_table().condition = condition;
1789 path->append().children = children;
1793 path->set_init_cost(
AddCost(
path->init_cost(), child.path->init_cost()));
1794 path->set_init_once_cost(
path->init_once_cost() +
1795 child.path->init_once_cost());
1797 AddRowCount(num_output_rows, child.path->num_output_rows());
1799 path->set_num_output_rows(num_output_rows);
1806 int ref_slice,
bool needs_buffering) {
1809 path->window().child = child;
1810 path->window().window = window;
1811 path->window().temp_table =
nullptr;
1812 path->window().temp_table_param = temp_table_param;
1813 path->window().ref_slice = ref_slice;
1814 path->window().needs_buffering = needs_buffering;
1815 path->set_num_output_rows(child->num_output_rows());
1823 path->weedout().child = child;
1824 path->weedout().weedout_table = weedout_table;
1825 path->weedout().tables_to_get_rowid_for =
1831 THD *thd,
AccessPath *child, std::span<Item *> group_items) {
1834 path->remove_duplicates().child = child;
1835 path->remove_duplicates().group_items() = group_items;
1836 path->has_group_skip_scan = child->has_group_skip_scan;
1842 unsigned loosescan_key_len) {
1845 path->remove_duplicates_on_index().child = child;
1846 path->remove_duplicates_on_index().table =
table;
1847 path->remove_duplicates_on_index().key =
key;
1848 path->remove_duplicates_on_index().loosescan_key_len = loosescan_key_len;
1849 path->has_group_skip_scan = child->has_group_skip_scan;
1858 path->alternative().table_scan_path = table_scan_path;
1859 path->alternative().child = child;
1860 path->alternative().used_ref = used_ref;
1868 path->cache_invalidator().child = child;
1869 path->cache_invalidator().name =
name;
1906 bool eligible_for_batch_mode);
1914 eligible_for_batch_mode);
1918 const POSITION *pos,
bool is_after_filter,
1994 int num_filter_predicates);
2019 int num_filter_predicates,
2042 const std::vector<HashJoinCondition> &equijoin_conditions,
constexpr double kUnknownCost
To indicate that a cost estimate is not yet made.
Definition: access_path.h:206
bool ApplySecondaryEngineNrowsHook(const SecondaryEngineNrowsParameters ¶ms)
Applies the secondary storage engine nrows modification function, if any.
Definition: access_path.cc:110
void ExpandSingleFilterAccessPath(THD *thd, const JoinHypergraph &graph, AccessPath *path, const JOIN *join)
Like ExpandFilterAccessPaths(), but expands only the single access path at “path”.
Definition: access_path.cc:1712
AccessPath * NewStreamingAccessPath(THD *thd, AccessPath *child, JOIN *join, Temp_table_param *temp_table_param, TABLE *table, int ref_slice)
Definition: access_path.cc:117
AccessPath * NewInvalidatorAccessPath(THD *thd, AccessPath *child, const char *name)
Definition: access_path.h:1864
AccessPath * NewRemoveDuplicatesAccessPath(THD *thd, AccessPath *child, std::span< Item * > group_items)
Definition: access_path.h:1830
AccessPath * NewRefAccessPath(THD *thd, TABLE *table, Index_lookup *ref, bool use_order, bool reverse, bool count_examined_rows)
Definition: access_path.h:1425
AccessPath * NewDeleteRowsAccessPath(THD *thd, AccessPath *child, table_map delete_tables, table_map immediate_tables)
Definition: access_path.cc:170
void CopyBasicProperties(const AccessPath &from, AccessPath *to)
Definition: access_path.h:1375
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:1474
double AddRowCount(double c1, double c2)
Add row counts c1 and c2, but handle kUnknownRowCount correctly.
Definition: access_path.h:1772
AccessPath * NewUpdateRowsAccessPath(THD *thd, AccessPath *child, table_map update_tables, table_map immediate_tables)
Definition: access_path.cc:182
table_map GetHashJoinTables(AccessPath *path)
Returns the tables that are part of a hash join.
Definition: access_path.cc:1872
AccessPath * NewDynamicIndexRangeScanAccessPath(THD *thd, TABLE *table, QEP_TAB *qep_tab, bool count_examined_rows)
Definition: access_path.h:1528
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, MaterializePathParameters::DedupType dedup_reason=MaterializePathParameters::NO_DEDUP)
Definition: access_path.h:1696
AccessPath * NewZeroRowsAggregatedAccessPath(THD *thd, const char *cause)
Definition: access_path.h:1665
AccessPath * NewAlternativeAccessPath(THD *thd, AccessPath *child, AccessPath *table_scan_path, Index_lookup *used_ref)
Definition: access_path.h:1853
AccessPath * NewMRRAccessPath(THD *thd, TABLE *table, Index_lookup *ref, int mrr_flags)
Definition: access_path.h:1505
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:419
Item * ConditionFromFilterPredicates(const Mem_root_array< Predicate > &predicates, OverflowBitset mask, int num_filter_predicates)
Extracts the Item expression from the given “filter_predicates” corresponding to the given “mask”.
Definition: access_path.cc:1701
AccessPath * NewAppendAccessPath(THD *thd, Mem_root_array< AppendPathParameters > *children)
Definition: access_path.h:1785
AccessPath * NewNestedLoopSemiJoinWithDuplicateRemovalAccessPath(THD *thd, AccessPath *outer, AccessPath *inner, const TABLE *table, KEY *key, size_t key_len)
Definition: access_path.h:1558
std::string_view AccessPathTypeName(AccessPath::Type type)
Return the name of an AccessPath::Type enumerator.
Definition: access_path.cc:320
void CollectStatusVariables(THD *thd, const JOIN *top_join, const AccessPath &top_path)
Update status variables which count how many scans of various types are used in a query plan.
Definition: access_path.cc:1886
MutableOverflowBitset ClearFilterPredicates(OverflowBitset predicates, int num_filter_predicates, MEM_ROOT *mem_root)
Clear all the bits representing filter predicates in a bitset, and keep only the bits representing ap...
Definition: access_path.cc:1863
AccessPath * NewTemptableAggregateAccessPath(THD *thd, AccessPath *subquery_path, JOIN *join, Temp_table_param *temp_table_param, TABLE *table, AccessPath *table_path, int ref_slice)
Definition: access_path.h:1599
AccessPath * NewRemoveDuplicatesOnIndexAccessPath(THD *thd, AccessPath *child, TABLE *table, KEY *key, unsigned loosescan_key_len)
Definition: access_path.h:1840
AccessPath * NewFakeSingleRowAccessPath(THD *thd, bool count_examined_rows)
Definition: access_path.h:1634
AccessPath * NewTableValueConstructorAccessPath(const THD *thd, const JOIN *join)
Definition: access_path.cc:214
AccessPath * NewFilterAccessPath(THD *thd, AccessPath *child, Item *condition)
Definition: access_path.h:1573
constexpr double kUnknownRowCount
To indicate that a row estimate is not yet made.
Definition: access_path.h:201
void ExpandFilterAccessPaths(THD *thd, const JoinHypergraph &graph, AccessPath *path, const JOIN *join)
For each access path in the (sub)tree rooted at “path”, expand any use of “filter_predicates” into ne...
Definition: access_path.cc:1854
AccessPath * NewSortAccessPath(THD *thd, AccessPath *child, Filesort *filesort, ORDER *order, bool count_examined_rows)
Definition: access_path.cc:135
bool IsSecondaryEngineNrowsHookApplicable(AccessPath *path, const JoinHypergraph *graph)
Returns whether SecondaryNrows is applicable given the parameters.
Definition: access_path.cc:101
AccessPath * NewMaterializedTableFunctionAccessPath(THD *thd, TABLE *table, Table_function *table_function, AccessPath *table_path)
Definition: access_path.h:1538
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:450
AccessPath * NewTableScanAccessPath(THD *thd, TABLE *table, bool count_examined_rows)
Definition: access_path.h:1392
AccessPath * NewSampleScanAccessPath(THD *thd, TABLE *table, double sampling_percentage, bool count_examined_rows)
Definition: access_path.h:1401
AccessPath * NewAggregateAccessPath(THD *thd, AccessPath *child, olap_type olap)
Definition: access_path.h:1589
double AddCost(double c1, double c2)
Add path costs c1 and c2, but handle kUnknownCost correctly.
Definition: access_path.h:1760
AccessPath * NewMaterializeInformationSchemaTableAccessPath(THD *thd, AccessPath *table_path, Table_ref *table_list, Item *condition)
Definition: access_path.h:1749
void FindTablesToGetRowidFor(AccessPath *path)
Modifies "path" and the paths below it so that they provide row IDs for all tables.
Definition: access_path.cc:1537
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:263
AccessPath * NewRefOrNullAccessPath(THD *thd, TABLE *table, Index_lookup *ref, bool use_order, bool count_examined_rows)
Definition: access_path.h:1438
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:1614
AccessPath * NewEQRefAccessPath(THD *thd, TABLE *table, Index_lookup *ref, bool count_examined_rows)
Definition: access_path.h:1450
AccessPath * NewWindowAccessPath(THD *thd, AccessPath *child, Window *window, Temp_table_param *temp_table_param, int ref_slice, bool needs_buffering)
Definition: access_path.h:1803
double FirstRowCost(double init_cost, double total_cost, double output_rows)
Calculate the cost of reading the first row from an access path, given estimates for init cost,...
Definition: access_path.h:210
AccessPath * NewFollowTailAccessPath(THD *thd, TABLE *table, bool count_examined_rows)
Definition: access_path.h:1519
AccessPath * NewConstTableAccessPath(THD *thd, TABLE *table, Index_lookup *ref, bool count_examined_rows)
Definition: access_path.h:1490
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:686
AccessPath * NewWeedoutAccessPath(THD *thd, AccessPath *child, SJ_TMP_TABLE *weedout_table)
Definition: access_path.h:1819
AccessPath * NewPushedJoinRefAccessPath(THD *thd, TABLE *table, Index_lookup *ref, bool use_order, bool is_unique, bool count_examined_rows)
Definition: access_path.h:1460
AccessPath * NewZeroRowsAccessPath(THD *thd, AccessPath *child, const char *cause)
Definition: access_path.h:1646
AccessPath * NewUnqualifiedCountAccessPath(THD *thd)
Definition: access_path.h:1549
AccessPath * NewIndexScanAccessPath(THD *thd, TABLE *table, int idx, bool use_order, bool reverse, bool count_examined_rows)
Definition: access_path.h:1412
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:1681
After parsing, a Common Table Expression is accessed through a Table_ref.
Definition: table.h:4611
API for getting cost estimates for server operations that are not directly related to a table object.
Definition: opt_costmodel.h:54
Sorting related info.
Definition: filesort.h:52
A class that represents a join condition in a hash join.
Definition: item_cmpfunc.h:92
Definition: item_func.h:3618
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:929
Definition: sql_optimizer.h:133
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:432
Definition: overflow_bitset.h:179
Definition: overflow_bitset.h:81
Definition: sql_executor.h:256
Definition: range_optimizer.h:69
This class represents a query expression (one query block or several query blocks combined with UNION...
Definition: sql_lex.h:662
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:82
Definition: sql_executor.h:95
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
MEM_ROOT * mem_root
Definition: sql_lexer_thd.h:40
Class representing a table function.
Definition: table_function.h:53
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:97
Represents the (explicit) window of a SQL 2003 section 7.11 <window clause>, or the implicit (inlined...
Definition: window.h:110
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
void EstimateLimitOffsetCost(AccessPath *path)
Estimate the costs and row count for a WINDOW AccessPath.
Definition: cost_model.cc:1690
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:367
void SetCostOnTableAccessPath(const Cost_model_server &cost_model, const POSITION *pos, bool is_after_filter, AccessPath *path)
Definition: sql_executor.cc:2009
std::bitset< kMaxSupportedFDs > FunctionalDependencySet
Definition: interesting_orders_defs.h:63
JoinType
Definition: join_type.h:28
unsigned char byte
Blob class.
Definition: common.h:151
static mi_bit_type mask[]
Definition: mi_packrec.cc:141
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:480
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1228
#define HA_POS_ERROR
Definition: my_base.h:1230
uint64_t table_map
Definition: my_table_map.h:30
static char * path
Definition: mysqldump.cc:151
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
PT & ref(PT *tp)
Definition: tablespace_impl.cc:359
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:40
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
RangeReverse< Range > reverse(Range &x)
Iterate over a range in reverse.
Definition: utilities.h:132
std::string join(const detail::range auto &rng, std::string_view delim)
join elements of a range into a string separated by a delimiter.
Definition: string.h:74
int delete_tables(PFS_engine_table_share_proxy **, unsigned int) noexcept
Definition: pfs_plugin_table_v1_all_empty.cc:39
olap_type
Definition: olap.h:31
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:60
required string type
Definition: replication_group_member_actions.proto:34
case opt name
Definition: sslopt-case.h:29
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:243
auto & weedout()
Definition: access_path.h:875
auto & filter()
Definition: access_path.h:795
bool count_all_rows
Definition: access_path.h:1265
AccessPath * bka_path
Definition: access_path.h:1034
struct AccessPath::@67::@97 filter
auto & ref_or_null()
Definition: access_path.h:603
auto & materialized_table_function()
Definition: access_path.h:715
AccessPath * cpk_child
Definition: access_path.h:1095
auto & rowid_union()
Definition: access_path.h:683
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:547
const auto & bka_join() const
Definition: access_path.h:775
struct AccessPath::@67::@93 hash_join
TABLE * temp_table
Definition: access_path.h:1305
OverflowBitset equijoin_predicates
Definition: access_path.h:1205
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:445
auto & materialize()
Definition: access_path.h:843
const auto & temptable_aggregate() const
Definition: access_path.h:823
OverflowBitset & subsumed_sargable_join_predicates()
Similar to applied_sargable_join_predicates, bitmap of sargable join predicates that have been applie...
Definition: access_path.h:519
auto & index_scan()
Definition: access_path.h:579
struct AccessPath::@67::@85 group_index_skip_scan
struct AccessPath::@67::@79 follow_tail
const auto & delete_rows() const
Definition: access_path.h:919
struct AccessPath::@67::@92 zero_rows_aggregated
struct AccessPath::@67::@89 table_value_constructor
const auto & filter() const
Definition: access_path.h:799
struct AccessPath::@67::@84 index_skip_scan
struct AccessPath::@67::@77 const_table
const auto & index_distance_scan() const
Definition: access_path.h:591
auto & delete_rows()
Definition: access_path.h:915
bool reuse_handler
Definition: access_path.h:1072
KEY_PART * used_key_part
Definition: access_path.h:1046
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:954
olap_type olap
Definition: access_path.h:1251
struct AccessPath::@67::@73 ref_or_null
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:494
Item * condition
Definition: access_path.h:1223
const auto & index_merge() const
Definition: access_path.h:671
const auto & update_rows() const
Definition: access_path.h:927
double subquery_rows
The number of materialized rows (as opposed to the number of rows fetched by table_path).
Definition: access_path.h:1292
enum AccessPath::Type type
auto & alternative()
Definition: access_path.h:899
auto & pushed_join_ref()
Definition: access_path.h:619
void set_cost(double val)
Definition: access_path.h:415
AccessPath * outer
Definition: access_path.h:1179
std::span< Item * > ItemSpan
Definition: access_path.h:1316
auto & index_skip_scan()
Definition: access_path.h:691
bool rewrite_semi_to_inner
Definition: access_path.h:1183
const auto & zero_rows_aggregated() const
Definition: access_path.h:759
auto & group_index_skip_scan()
Definition: access_path.h:699
struct AccessPath::@67::@107 weedout
const auto & eq_ref() const
Definition: access_path.h:615
bool use_order
Definition: access_path.h:990
bool pfs_batch_mode
Definition: access_path.h:1197
auto & temptable_aggregate()
Definition: access_path.h:819
GroupIndexSkipScanParameters * param
Definition: access_path.h:1139
auto & rowid_intersection()
Definition: access_path.h:675
double init_cost() const
Definition: access_path.h:404
bool materialize_subqueries
Definition: access_path.h:1233
AccessPath * child
Definition: access_path.h:1167
bool allow_spill_to_disk
Definition: access_path.h:1181
struct AccessPath::@67::@82 rowid_intersection
struct AccessPath::@67::@83 rowid_union
Index_lookup * used_ref
Definition: access_path.h:1347
auto & mrr()
Definition: access_path.h:643
std::byte m_group_items[sizeof(ItemSpan)]
Definition: access_path.h:1334
auto & sample_scan()
Definition: access_path.h:571
const auto & index_scan() const
Definition: access_path.h:583
const auto & fake_single_row() const
Definition: access_path.h:743
struct AccessPath::@67::@102 stream
bool reject_multiple_rows
Definition: access_path.h:1266
struct AccessPath::@67::@81 index_merge
bool allow_clustered_primary_key_scan
Definition: access_path.h:1087
const char * name
Definition: access_path.h:1351
bool use_limit
Definition: access_path.h:1024
Window * window
Definition: access_path.h:1304
table_map tables_to_get_rowid_for
Definition: access_path.h:1184
auto & materialize_information_schema_table()
Definition: access_path.h:851
auto & bka_join()
Definition: access_path.h:771
struct AccessPath::@67::@96 nested_loop_semijoin_with_duplicate_removal
const auto & follow_tail() const
Definition: access_path.h:655
SJ_TMP_TABLE * weedout_table
Definition: access_path.h:1312
bool has_group_skip_scan
Whether this access path contains a GROUP_INDEX_SKIP_SCAN.
Definition: access_path.h:339
Index_lookup * ref
Definition: access_path.h:1001
struct AccessPath::@67::@101 limit_offset
const auto & window() const
Definition: access_path.h:871
void set_init_once_cost(double val)
Definition: access_path.h:427
const auto & materialized_table_function() const
Definition: access_path.h:719
auto & unqualified_count()
Definition: access_path.h:723
bool keep_current_rowid
Definition: access_path.h:1036
bool using_extended_key_parts
Definition: access_path.h:1082
auto & nested_loop_join()
Definition: access_path.h:779
const auto & full_text_search() const
Definition: access_path.h:631
struct AccessPath::@67::@87 materialized_table_function
bool can_be_used_for_ror
Definition: access_path.h:1062
float rec_per_key
Definition: access_path.h:1190
Safety safe_for_rowid
Whether it is safe to get row IDs (for sorting) from this access path.
Definition: access_path.h:330
JOIN * join
Definition: access_path.h:1255
unsigned index
Definition: access_path.h:1058
unsigned mrr_buf_size
Definition: access_path.h:1054
auto & remove_duplicates()
Definition: access_path.h:883
RowIterator * iterator
If an iterator has been instantiated for this access path, points to the iterator.
Definition: access_path.h:400
const auto & stream() const
Definition: access_path.h:839
struct AccessPath::@67::@71 index_distance_scan
const auto & remove_duplicates() const
Definition: access_path.h:887
auto & window()
Definition: access_path.h:867
bool need_rows_in_rowid_order
Definition: access_path.h:1066
Table_ref * table_list
Definition: access_path.h:1296
const auto & unqualified_count() const
Definition: access_path.h:727
void * secondary_engine_data
Auxiliary data used by a secondary storage engine while processing the access path during optimizatio...
Definition: access_path.h:556
struct AccessPath::@67::@68 table_scan
struct AccessPath::@67::@110 alternative
void set_init_cost(double val)
Definition: access_path.h:421
void set_num_output_rows(double val)
Definition: access_path.h:934
bool is_covering
Definition: access_path.h:1115
const auto & mrr() const
Definition: access_path.h:647
void set_cost_before_filter(double val)
Definition: access_path.h:433
bool remove_duplicates
Definition: access_path.h:1245
table_map tables_to_update
Definition: access_path.h:1360
const auto & table_value_constructor() const
Definition: access_path.h:735
KEY * key
Definition: access_path.h:1217
bool HasConsistentCostsAndRows(const JoinHypergraph &graph) const
Return true if costs and row counts are consistent.
Definition: access_path.cc:1964
auto & table_value_constructor()
Definition: access_path.h:731
auto & stream()
Definition: access_path.h:835
size_t key_len
Definition: access_path.h:1218
const OverflowBitset & subsumed_sargable_join_predicates() const
Definition: access_path.h:522
const auto & zero_rows() const
Definition: access_path.h:751
const auto & append() const
Definition: access_path.h:863
ha_rows offset
Definition: access_path.h:1264
int idx
Definition: access_path.h:989
auto & hash_join()
Definition: access_path.h:763
auto & cache_invalidator()
Definition: access_path.h:907
struct AccessPath::@67::@90 fake_single_row
bool force_sort_rowids
Definition: access_path.h:1247
unsigned num_used_key_parts
Definition: access_path.h:1059
unsigned num_ranges
Definition: access_path.h:1051
ORDER * order
Definition: access_path.h:1243
auto & sort()
Definition: access_path.h:803
struct AccessPath::@67::@80 index_range_scan
auto & fake_single_row()
Definition: access_path.h:739
ha_rows limit
Definition: access_path.h:1244
auto & follow_tail()
Definition: access_path.h:651
double m_num_output_rows
Expected number of output rows.
Definition: access_path.h:942
const auto & sample_scan() const
Definition: access_path.h:575
const JoinPredicate * join_predicate
Definition: access_path.h:1180
const auto & const_table() const
Definition: access_path.h:639
const auto & dynamic_index_range_scan() const
Definition: access_path.h:711
const auto & table_scan() const
Definition: access_path.h:567
struct AccessPath::@67::@70 index_scan
unsigned mrr_flags
Definition: access_path.h:1053
int ref_slice
Definition: access_path.h:1259
struct AccessPath::@67::@112 delete_rows
OverflowBitset filter_predicates
Bitmap of WHERE predicates that we are including on this access path, referring to the “predicates” a...
Definition: access_path.h:478
bool can_be_used_for_imerge
Definition: access_path.h:1069
bool forced_by_hint
Definition: access_path.h:1086
auto & limit_offset()
Definition: access_path.h:827
AccessPath * inner
Definition: access_path.h:1179
QUICK_RANGE * range
Definition: access_path.h:996
bool provide_rowid
Definition: access_path.h:1276
const auto & index_range_scan() const
Definition: access_path.h:663
struct AccessPath::@67::@99 aggregate
struct AccessPath::@67::@75 pushed_join_ref
const auto & ref() const
Definition: access_path.h:599
struct AccessPath::@67::@91 zero_rows
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:344
Item_func_match * ft_func
Definition: access_path.h:1025
ha_rows * send_records_override
Definition: access_path.h:1269
auto & table_scan()
Definition: access_path.h:563
const auto & hash_join() const
Definition: access_path.h:767
QEP_TAB * qep_tab
Definition: access_path.h:1143
Table_function * table_function
Definition: access_path.h:1147
struct AccessPath::@67::@109 remove_duplicates_on_index
auto & zero_rows_aggregated()
Definition: access_path.h:755
const auto & sort() const
Definition: access_path.h:807
bool unwrap_rollup
Definition: access_path.h:1246
struct AccessPath::@67::@74 eq_ref
struct AccessPath::@67::@94 bka_join
struct AccessPath::@67::@78 mrr
Type
Definition: access_path.h:244
@ FOLLOW_TAIL
Definition: access_path.h:259
@ FILTER
Definition: access_path.h:283
@ PUSHED_JOIN_REF
Definition: access_path.h:255
@ ZERO_ROWS_AGGREGATED
Definition: access_path.h:272
@ UPDATE_ROWS
Definition: access_path.h:301
@ AGGREGATE
Definition: access_path.h:285
@ BKA_JOIN
Definition: access_path.h:279
@ ZERO_ROWS
Definition: access_path.h:271
@ CONST_TABLE
Definition: access_path.h:257
@ GROUP_INDEX_SKIP_SCAN
Definition: access_path.h:265
@ SAMPLE_SCAN
Definition: access_path.h:249
@ INDEX_RANGE_SCAN
Definition: access_path.h:260
@ UNQUALIFIED_COUNT
Definition: access_path.h:274
@ EQ_REF
Definition: access_path.h:254
@ FAKE_SINGLE_ROW
Definition: access_path.h:270
@ MATERIALIZE_INFORMATION_SCHEMA_TABLE
Definition: access_path.h:290
@ WINDOW
Definition: access_path.h:292
@ REF_OR_NULL
Definition: access_path.h:253
@ MATERIALIZE
Definition: access_path.h:289
@ NESTED_LOOP_SEMIJOIN_WITH_DUPLICATE_REMOVAL
Definition: access_path.h:278
@ ROWID_UNION
Definition: access_path.h:263
@ INDEX_SKIP_SCAN
Definition: access_path.h:264
@ MRR
Definition: access_path.h:258
@ CACHE_INVALIDATOR
Definition: access_path.h:297
@ INDEX_SCAN
Definition: access_path.h:250
@ TABLE_VALUE_CONSTRUCTOR
Definition: access_path.h:269
@ WEEDOUT
Definition: access_path.h:293
@ MATERIALIZED_TABLE_FUNCTION
Definition: access_path.h:273
@ REMOVE_DUPLICATES_ON_INDEX
Definition: access_path.h:295
@ TABLE_SCAN
Definition: access_path.h:248
@ REF
Definition: access_path.h:252
@ TEMPTABLE_AGGREGATE
Definition: access_path.h:286
@ LIMIT_OFFSET
Definition: access_path.h:287
@ APPEND
Definition: access_path.h:291
@ NESTED_LOOP_JOIN
Definition: access_path.h:277
@ INDEX_MERGE
Definition: access_path.h:261
@ FULL_TEXT_SEARCH
Definition: access_path.h:256
@ ALTERNATIVE
Definition: access_path.h:296
@ STREAM
Definition: access_path.h:288
@ REMOVE_DUPLICATES
Definition: access_path.h:294
@ ROWID_INTERSECTION
Definition: access_path.h:262
@ DYNAMIC_INDEX_RANGE_SCAN
Definition: access_path.h:266
@ DELETE_ROWS
Definition: access_path.h:300
@ SORT
Definition: access_path.h:284
@ INDEX_DISTANCE_SCAN
Definition: access_path.h:251
@ HASH_JOIN
Definition: access_path.h:280
bool retrieve_full_rows
Definition: access_path.h:1098
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:966
struct AccessPath::@67::@86 dynamic_index_range_scan
const auto & rowid_union() const
Definition: access_path.h:687
const TABLE * table
Definition: access_path.h:1216
const auto & index_skip_scan() const
Definition: access_path.h:695
auto & dynamic_index_range_scan()
Definition: access_path.h:707
const auto & pushed_join_ref() const
Definition: access_path.h:623
struct AccessPath::@67::@111 cache_invalidator
auto & remove_duplicates_on_index()
Definition: access_path.h:891
table_map immediate_tables
Definition: access_path.h:1356
double m_cost_before_filter
If no filter, identical to cost.
Definition: access_path.h:970
double cost() const
Definition: access_path.h:402
struct AccessPath::@67::@88 unqualified_count
int mrr_flags
Definition: access_path.h:1035
auto & full_text_search()
Definition: access_path.h:627
const auto & materialize() const
Definition: access_path.h:847
int ordering_state
Which ordering the rows produced by this path follow, if any (see interesting_orders....
Definition: access_path.h:394
auto & eq_ref()
Definition: access_path.h:611
JoinType join_type
Definition: access_path.h:1188
const auto & limit_offset() const
Definition: access_path.h:831
MaterializePathParameters * param
Definition: access_path.h:1287
const char * cause
Definition: access_path.h:1170
auto & update_rows()
Definition: access_path.h:923
auto & index_merge()
Definition: access_path.h:667
auto & aggregate()
Definition: access_path.h:811
struct AccessPath::@67::@104 materialize_information_schema_table
double m_cost
Expected cost to read all of this access path once.
Definition: access_path.h:945
const auto & group_index_skip_scan() const
Definition: access_path.h:703
auto & zero_rows()
Definition: access_path.h:747
AccessPath * subquery_path
Definition: access_path.h:1254
Mem_root_array< AppendPathParameters > * children
Definition: access_path.h:1300
const auto & nested_loop_join() const
Definition: access_path.h:783
bool already_expanded_predicates
Definition: access_path.h:1198
const auto & remove_duplicates_on_index() const
Definition: access_path.h:895
Temp_table_param * temp_table_param
Definition: access_path.h:1256
auto & nested_loop_semijoin_with_duplicate_removal()
Definition: access_path.h:787
bool reverse
Definition: access_path.h:991
AccessPath * table_scan_path
Definition: access_path.h:1343
struct AccessPath::@67::@113 update_rows
struct AccessPath::@67::@98 sort
enum tablesample_type sampling_type
Definition: access_path.h:985
const auto & materialize_information_schema_table() const
Definition: access_path.h:855
double subquery_cost
The total cost of executing the queries that we materialize.
Definition: access_path.h:1289
bool geometry
Definition: access_path.h:1075
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:336
unsigned loosescan_key_len
Definition: access_path.h:1340
auto & index_distance_scan()
Definition: access_path.h:587
auto & ref()
Definition: access_path.h:595
struct AccessPath::@67::@100 temptable_aggregate
double first_row_cost() const
The cost of reading the first row.
Definition: access_path.h:407
table_map tables_to_delete_from
Definition: access_path.h:1355
struct AccessPath::@67::@69 sample_scan
double init_once_cost() const
Definition: access_path.h:411
IndexSkipScanParameters * param
Definition: access_path.h:1130
const OverflowBitset & applied_sargable_join_predicates() const
Definition: access_path.h:497
Mem_root_array< AccessPath * > * children
Definition: access_path.h:1088
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:511
AccessPath * table_path
Definition: access_path.h:1148
const auto & aggregate() const
Definition: access_path.h:815
TABLE * table
Definition: access_path.h:980
auto & append()
Definition: access_path.h:859
double cost_before_filter() const
Definition: access_path.h:413
const auto & weedout() const
Definition: access_path.h:879
const auto & cache_invalidator() const
Definition: access_path.h:911
double sampling_percentage
Definition: access_path.h:984
bool needs_buffering
Definition: access_path.h:1308
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:388
QUICK_RANGE ** ranges
Definition: access_path.h:1050
bool is_unique
Definition: access_path.h:1018
const auto & alternative() const
Definition: access_path.h:903
Safety
A general enum to describe the safety of a given operation.
Definition: access_path.h:311
@ 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:320
@ UNSAFE
The given operation is unsafe on this access path, no matter how many or few times it's scanned.
Definition: access_path.h:326
@ SAFE
The given operation is always safe on this access path.
Definition: access_path.h:313
struct AccessPath::@67::@103 materialize
auto & const_table()
Definition: access_path.h:635
unsigned mrr_length_per_rec
Definition: access_path.h:1189
struct AccessPath::@67::@76 full_text_search
const auto & rowid_intersection() const
Definition: access_path.h:679
Mem_root_array< Item_values_column * > * output_refs
Definition: access_path.h:1154
auto & index_range_scan()
Definition: access_path.h:659
double num_output_rows() const
Definition: access_path.h:932
double num_output_rows_before_filter
If no filter, identical to num_output_rows.
Definition: access_path.h:451
size_t signature
Signature used to uniquely identify the access path.
Definition: access_path.h:560
const auto & ref_or_null() const
Definition: access_path.h:607
struct AccessPath::@67::@95 nested_loop_join
Filesort * filesort
Definition: access_path.h:1237
struct AccessPath::@67::@105 append
bool store_rowids
Definition: access_path.h:1182
const auto & nested_loop_semijoin_with_duplicate_removal() const
Definition: access_path.h:791
Definition: access_path.h:195
JOIN * join
Definition: access_path.h:197
AccessPath * path
Definition: access_path.h:196
Definition: group_index_skip_scan_plan.h:45
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:73
Structure used for index-based lookups.
Definition: sql_opt_exec_shared.h:67
A struct containing a join hypergraph of a single query block, encapsulating the constraints given by...
Definition: make_join_hypergraph.h:99
A specification that two specific relational expressions (e.g., two tables, or a table and a join bet...
Definition: access_path.h:80
FunctionalDependencySet functional_dependencies
Definition: access_path.h:102
Mem_root_array< int > functional_dependencies_idx
Definition: access_path.h:107
RelationalExpression * expr
Definition: access_path.h:81
double selectivity
Definition: access_path.h:82
int ordering_idx_needed_for_semijoin_rewrite
Definition: access_path.h:125
size_t estimated_hash_join_key_width
Definition: access_path.h:91
std::span< Item * > semijoin_group
Definition: access_path.h:130
size_t estimated_bytes_per_row
Definition: access_path.h:86
Definition: range_optimizer.h:55
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: materialize_path_parameters.h:42
AccessPath * subquery_path
Definition: materialize_path_parameters.h:43
int select_number
Definition: materialize_path_parameters.h:44
JOIN * join
Definition: materialize_path_parameters.h:45
bool copy_items
Definition: materialize_path_parameters.h:47
Temp_table_param * temp_table_param
Definition: materialize_path_parameters.h:48
bool disable_deduplication_by_hash_field
Definition: materialize_path_parameters.h:46
Definition: materialize_path_parameters.h:40
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:80
DedupType deduplication_reason
Definition: materialize_path_parameters.h:111
Mem_root_array< Operand > m_operands
Definition: materialize_path_parameters.h:58
Common_table_expr * cte
If materializing a CTE, points to it (see m_cte), otherwise nullptr.
Definition: materialize_path_parameters.h:65
DedupType
The context for which deduplication is being used.
Definition: materialize_path_parameters.h:106
@ NO_DEDUP
Definition: materialize_path_parameters.h:109
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:99
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:92
TABLE * table
Handle to table to materialize into.
Definition: materialize_path_parameters.h:62
int ref_slice
Definition: materialize_path_parameters.h:74
Query_expression * unit
The query expression we are materializing.
Definition: materialize_path_parameters.h:68
Mem_root_array< const AccessPath * > * invalidators
Definition: materialize_path_parameters.h:59
A position of table within a join order.
Definition: sql_select.h:355
A filter of some sort that is not a join condition (those are stored in JoinPredicate objects).
Definition: access_path.h:138
hypergraph::NodeMap total_eligibility_set
Definition: access_path.h:151
bool was_join_condition
Definition: access_path.h:164
Mem_root_array< int > functional_dependencies_idx
Definition: access_path.h:187
bool possibly_null_complemented_later
Definition: access_path.h:175
FunctionalDependencySet functional_dependencies
Definition: access_path.h:186
int source_multiple_equality_idx
Definition: access_path.h:183
hypergraph::NodeMap used_nodes
Definition: access_path.h:142
Item * condition
Definition: access_path.h:139
double selectivity
Definition: access_path.h:153
Mem_root_array< ContainedSubquery > contained_subqueries
Definition: access_path.h:192
Represents an expression tree in the relational algebra of joins.
Definition: relational_expression.h:155
Type for signature generation and for retrieving nrows estimate from secondary engine for current Acc...
Definition: handler.h:2486
tablesample_type
Definition: tablesample.h:27