![]() |
MySQL 9.7.0
Source Code Documentation
|
A struct containing a join hypergraph of a single query block, encapsulating the constraints given by the relational expressions (e.g. More...
#include <make_join_hypergraph.h>
Classes | |
| class | Node |
Public Types | |
| using | secondary_engine_nrows_hook_t = bool(*)(const SecondaryEngineNrowsParameters ¶ms) |
Public Member Functions | |
| JoinHypergraph (MEM_ROOT *mem_root, const Query_block *query_block) | |
| std::span< const Predicate > | filter_predicates () const |
| Returns an immutable view of the filter predicates portion of the predicates array. More... | |
| std::span< Predicate > | filter_predicates () |
| Returns a mutable view of the filter predicates portion of the predicates array. More... | |
| const Query_block * | query_block () const |
| Returns a pointer to the query block that is being planned. More... | |
| const JOIN * | join () const |
| Returns a pointer to the JOIN object of the query block being planned. More... | |
| int | FindSargableJoinPredicate (const Item *predicate) const |
| void | AddSargableJoinPredicate (const Item *predicate, int position) |
| bool | has_secondary_engine_nrows_hook () const |
| Returns true if the secondary engine nrows hook is available. More... | |
| bool | call_secondary_engine_nrows_hook (const SecondaryEngineNrowsParameters ¶ms) const |
| Calls the secondary engine nrows hook. More... | |
| void | set_secondary_engine_nrows_hook (secondary_engine_nrows_hook_t secondary_engine_nrows_hook) |
| Sets the secondary engine nrows hook (nullptr means unavailable). More... | |
Public Attributes | |
| hypergraph::Hypergraph | graph |
| SecondaryEngineCostingFlags | secondary_engine_costing_flags {} |
| Flags set when AccessPaths are proposed to secondary engines for costing. More... | |
| std::array< int, MAX_TABLES > | table_num_to_node_num |
| Mem_root_array< Node > | nodes |
| Mem_root_array< JoinPredicate > | edges |
| Mem_root_array< Predicate > | predicates |
| unsigned | num_filter_predicates = 0 |
| OverflowBitset | materializable_predicates {0} |
| bool | has_reordered_left_joins = false |
| Whether, at any point, we could rewrite (t1 LEFT JOIN t2) LEFT JOIN t3 to t1 LEFT JOIN (t2 LEFT JOIN t3) or vice versa. More... | |
| bool | has_estimates_from_secondary_engine = false |
| hypergraph::NodeMap | nodes_inner_to_outer_join = 0 |
| The set of nodes that are on the inner side of some outer join. More... | |
| hypergraph::NodeMap | nodes_inner_to_semijoin = 0 |
| The set of nodes that are on the inner side of some semijoin. More... | |
| hypergraph::NodeMap | nodes_inner_to_antijoin = 0 |
| The set of nodes that are on the inner side of some antijoin. More... | |
| hypergraph::NodeMap | nodes_for_table_function = 0 |
| The set of nodes that are represented by table_function. More... | |
Private Attributes | |
| secondary_engine_nrows_hook_t | m_secondary_engine_nrows_hook = nullptr |
| mem_root_unordered_map< const Item *, int > | m_sargable_join_predicates |
| const Query_block * | m_query_block |
| A pointer to the query block being planned. More... | |
A struct containing a join hypergraph of a single query block, encapsulating the constraints given by the relational expressions (e.g.
inner joins are more freely reorderable than outer joins).
Since the Hypergraph class does not carry any payloads for nodes and edges, and we need to associate e.g. TABLE pointers with each node, we store our extra data in “nodes” and “edges”, indexed the same way the hypergraph is indexed.
| using JoinHypergraph::secondary_engine_nrows_hook_t = bool (*)(const SecondaryEngineNrowsParameters ¶ms) |
|
inline |
|
inline |
|
inline |
Calls the secondary engine nrows hook.
Requires has_secondary_engine_nrows_hook() == true; asserts otherwise.
|
inline |
Returns a mutable view of the filter predicates portion of the predicates array.
|
inline |
Returns an immutable view of the filter predicates portion of the predicates array.
|
inline |
|
inline |
Returns true if the secondary engine nrows hook is available.
| const JOIN * JoinHypergraph::join | ( | ) | const |
Returns a pointer to the JOIN object of the query block being planned.
|
inline |
Returns a pointer to the query block that is being planned.
|
inline |
Sets the secondary engine nrows hook (nullptr means unavailable).
| Mem_root_array<JoinPredicate> JoinHypergraph::edges |
| hypergraph::Hypergraph JoinHypergraph::graph |
| bool JoinHypergraph::has_estimates_from_secondary_engine = false |
| bool JoinHypergraph::has_reordered_left_joins = false |
Whether, at any point, we could rewrite (t1 LEFT JOIN t2) LEFT JOIN t3 to t1 LEFT JOIN (t2 LEFT JOIN t3) or vice versa.
We record this purely to note that we have a known bug/inconsistency in row count estimation in this case. Bug #33550360 has a test case, but to sum up: Assume t1 and t3 has 25 rows, but t2 has zero rows, and selectivities are 0.1. As long as we clamp the row count in FindOutputRowsForJoin(), and do not modify these selectivities somehow, the former would give 62.5 rows, and the second would give 25 rows. This should be fixed eventually, but for now, at least we register it, so that we do not assert-fail on inconsistent row counts if this (known) issue could be the root cause.
|
private |
A pointer to the query block being planned.
|
private |
|
private |
| OverflowBitset JoinHypergraph::materializable_predicates {0} |
| Mem_root_array<Node> JoinHypergraph::nodes |
| hypergraph::NodeMap JoinHypergraph::nodes_for_table_function = 0 |
The set of nodes that are represented by table_function.
This will be set only when optimizing for secondary engine.
| hypergraph::NodeMap JoinHypergraph::nodes_inner_to_antijoin = 0 |
The set of nodes that are on the inner side of some antijoin.
| hypergraph::NodeMap JoinHypergraph::nodes_inner_to_outer_join = 0 |
The set of nodes that are on the inner side of some outer join.
| hypergraph::NodeMap JoinHypergraph::nodes_inner_to_semijoin = 0 |
The set of nodes that are on the inner side of some semijoin.
| unsigned JoinHypergraph::num_filter_predicates = 0 |
| Mem_root_array<Predicate> JoinHypergraph::predicates |
| SecondaryEngineCostingFlags JoinHypergraph::secondary_engine_costing_flags {} |
Flags set when AccessPaths are proposed to secondary engines for costing.
The intention of these flags is to avoid traversing the AccessPath tree to check for certain criteria. TODO (tikoldit) Move to JOIN or Secondary_engine_execution_context, so that JoinHypergraph can be immutable during planning
| std::array<int, MAX_TABLES> JoinHypergraph::table_num_to_node_num |