MySQL 8.3.0
Source Code Documentation
build_interesting_orders.h File Reference

Go to the source code of this file.

Classes

struct  SortAheadOrdering
 
struct  ActiveIndexInfo
 
struct  SpatialDistanceScanInfo
 
struct  FullTextIndexInfo
 

Functions

void BuildInterestingOrders (THD *thd, JoinHypergraph *graph, Query_block *query_block, LogicalOrderings *orderings, Mem_root_array< SortAheadOrdering > *sort_ahead_orderings, int *order_by_ordering_idx, int *group_by_ordering_idx, int *distinct_ordering_idx, Mem_root_array< ActiveIndexInfo > *active_indexes, Mem_root_array< SpatialDistanceScanInfo > *spatial_indexes, Mem_root_array< FullTextIndexInfo > *fulltext_searches, std::string *trace)
 Build all structures we need for keeping track of interesting orders. More...
 
ORDERBuildSortAheadOrdering (THD *thd, const LogicalOrderings *orderings, Ordering ordering)
 
Ordering ReduceFinalOrdering (THD *thd, const LogicalOrderings &orderings, int ordering_idx)
 Creates a reduced ordering for the ordering or grouping specified by "ordering_idx". More...
 

Function Documentation

◆ BuildInterestingOrders()

void BuildInterestingOrders ( THD thd,
JoinHypergraph graph,
Query_block query_block,
LogicalOrderings orderings,
Mem_root_array< SortAheadOrdering > *  sort_ahead_orderings,
int *  order_by_ordering_idx,
int *  group_by_ordering_idx,
int *  distinct_ordering_idx,
Mem_root_array< ActiveIndexInfo > *  active_indexes,
Mem_root_array< SpatialDistanceScanInfo > *  spatial_indexes,
Mem_root_array< FullTextIndexInfo > *  fulltext_searches,
std::string *  trace 
)

Build all structures we need for keeping track of interesting orders.

We collect the actual relevant orderings (e.g. from ORDER BY) and any functional dependencies we can find, then ask LogicalOrderings to create its state machine (as defined in interesting_orders.h). The result is said state machine, a list of potential sort-ahead orderings, and a list of what indexes we can use to scan each table (including what orderings they yield, if they are interesting).

◆ BuildSortAheadOrdering()

ORDER * BuildSortAheadOrdering ( THD thd,
const LogicalOrderings orderings,
Ordering  ordering 
)

◆ ReduceFinalOrdering()

Ordering ReduceFinalOrdering ( THD thd,
const LogicalOrderings orderings,
int  ordering_idx 
)

Creates a reduced ordering for the ordering or grouping specified by "ordering_idx".

It is assumed that the ordering happens after all joins and filters, so that all functional dependencies are active. All parts of the ordering that are made redundant by functional dependencies, are removed.

The returned ordering may be empty if all elements are redundant. This happens if all elements are constants, or have predicates that ensure they are constant.