MySQL 8.0.40
Source Code Documentation
JoinHypergraph Struct Reference

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

struct  Node
 

Public Member Functions

 JoinHypergraph (MEM_ROOT *mem_root, const Query_block *query_block)
 
const Query_blockquery_block () const
 Returns a pointer to the query block that is being planned. More...
 
const JOINjoin () const
 Returns a pointer to the JOIN object of the query block being planned. 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_TABLEStable_num_to_node_num
 
Mem_root_array< Nodenodes
 
Mem_root_array< JoinPredicateedges
 
Mem_root_array< Predicatepredicates
 
unsigned num_where_predicates = 0
 
OverflowBitset materializable_predicates {0}
 
mem_root_unordered_map< Item *, int > sargable_join_predicates
 
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...
 
table_map tables_inner_to_outer_or_anti = 0
 The set of tables that are on the inner side of some outer join or antijoin. More...
 

Private Attributes

const Query_blockm_query_block
 A pointer to the query block being planned. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ JoinHypergraph()

JoinHypergraph::JoinHypergraph ( MEM_ROOT mem_root,
const Query_block query_block 
)
inline

Member Function Documentation

◆ join()

const JOIN * JoinHypergraph::join ( ) const

Returns a pointer to the JOIN object of the query block being planned.

◆ query_block()

const Query_block * JoinHypergraph::query_block ( ) const
inline

Returns a pointer to the query block that is being planned.

Member Data Documentation

◆ edges

Mem_root_array<JoinPredicate> JoinHypergraph::edges

◆ graph

hypergraph::Hypergraph JoinHypergraph::graph

◆ has_reordered_left_joins

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.

◆ m_query_block

const Query_block* JoinHypergraph::m_query_block
private

A pointer to the query block being planned.

◆ materializable_predicates

OverflowBitset JoinHypergraph::materializable_predicates {0}

◆ nodes

Mem_root_array<Node> JoinHypergraph::nodes

◆ num_where_predicates

unsigned JoinHypergraph::num_where_predicates = 0

◆ predicates

Mem_root_array<Predicate> JoinHypergraph::predicates

◆ sargable_join_predicates

mem_root_unordered_map<Item *, int> JoinHypergraph::sargable_join_predicates

◆ secondary_engine_costing_flags

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

◆ table_num_to_node_num

std::array<int, MAX_TABLES> JoinHypergraph::table_num_to_node_num

◆ tables_inner_to_outer_or_anti

table_map JoinHypergraph::tables_inner_to_outer_or_anti = 0

The set of tables that are on the inner side of some outer join or antijoin.

If a table is not part of this set, and it is found to be empty, we can assume that the result of the top-level join will also be empty.


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