MySQL 8.4.2
Source Code Documentation
make_join_hypergraph.h File Reference
#include <assert.h>
#include <algorithm>
#include <array>
#include <cstddef>
#include <string>
#include <unordered_map>
#include <utility>
#include "map_helpers.h"
#include "my_table_map.h"
#include "sql/item.h"
#include "sql/join_optimizer/access_path.h"
#include "sql/join_optimizer/hypergraph.h"
#include "sql/join_optimizer/node_map.h"
#include "sql/join_optimizer/overflow_bitset.h"
#include "sql/join_optimizer/secondary_engine_costing_flags.h"
#include "sql/mem_root_array.h"
#include "sql/sql_const.h"

Go to the source code of this file.

Classes

struct  SargablePredicate
 A sargable (from “Search ARGument”) predicate is one that we can attempt to push down into an index (what we'd call “ref access” or “index range scan”/“quick”). More...
 
struct  JoinHypergraph
 A struct containing a join hypergraph of a single query block, encapsulating the constraints given by the relational expressions (e.g. More...
 
class  JoinHypergraph::Node
 

Functions

bool MakeJoinHypergraph (THD *thd, JoinHypergraph *graph, bool *where_is_always_false)
 Make a join hypergraph from the query block given by “graph->query_block”, converting from MySQL's join list structures to the ones expected by the hypergraph join optimizer. More...
 
void MakeJoinGraphFromRelationalExpression (THD *thd, RelationalExpression *expr, JoinHypergraph *graph)
 Convert a join rooted at “expr” into a join hypergraph that encapsulates the constraints given by the relational expressions (e.g. More...
 
hypergraph::NodeMap GetNodeMapFromTableMap (table_map table_map, const std::array< int, MAX_TABLES > &table_num_to_node_num)
 
std::string PrintDottyHypergraph (const JoinHypergraph &graph)
 For the given hypergraph, make a textual representation in the form of a dotty graph. More...
 
size_t EstimateHashJoinKeyWidth (const RelationalExpression *expr)
 Estimates the size of the hash join keys generated from the equi-join predicates in "expr". More...
 
table_map GetVisibleTables (const RelationalExpression *expr)
 

Function Documentation

◆ EstimateHashJoinKeyWidth()

size_t EstimateHashJoinKeyWidth ( const RelationalExpression expr)

Estimates the size of the hash join keys generated from the equi-join predicates in "expr".

◆ GetNodeMapFromTableMap()

hypergraph::NodeMap GetNodeMapFromTableMap ( table_map  table_map,
const std::array< int, MAX_TABLES > &  table_num_to_node_num 
)

◆ GetVisibleTables()

table_map GetVisibleTables ( const RelationalExpression expr)

◆ MakeJoinGraphFromRelationalExpression()

void MakeJoinGraphFromRelationalExpression ( THD thd,
RelationalExpression expr,
JoinHypergraph graph 
)

Convert a join rooted at “expr” into a join hypergraph that encapsulates the constraints given by the relational expressions (e.g.

inner joins are more freely reorderable than outer joins).

The function in itself only does some bookkeeping around node bitmaps, and then defers the actual conflict detection logic to FindHyperedgeAndJoinConflicts().

◆ MakeJoinHypergraph()

bool MakeJoinHypergraph ( THD thd,
JoinHypergraph graph,
bool *  where_is_always_false 
)

Make a join hypergraph from the query block given by “graph->query_block”, converting from MySQL's join list structures to the ones expected by the hypergraph join optimizer.

This includes pushdown of WHERE predicates, and detection of conditions suitable for hash join. However, it does not include simplification of outer to inner joins; that is presumed to have happened earlier.

The result is suitable for running DPhyp (subgraph_enumeration.h) to find optimal join planning.

◆ PrintDottyHypergraph()

std::string PrintDottyHypergraph ( const JoinHypergraph graph)

For the given hypergraph, make a textual representation in the form of a dotty graph.

You can save this to a file and then use Graphviz to render this it a graphical representation of the hypergraph for easier debugging, e.g. like this:

dot -Tps graph.dot > graph.ps display graph.ps

See also Dbug_table_list_dumper.