MySQL 8.4.2
Source Code Documentation
anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters Struct Referencefinal

This struct implements a builder pattern for creating paths that do DISTINCT (sort with duplicate removal) and adding them as parent of the current candidate paths (except for candidate paths that do DISTINCT already). More...

Public Member Functions

AccessPathArray ApplyDistinct () const
 Create new root paths as needed to do DISTINCT. More...
 

Public Attributes

THDthd
 The current thread. More...
 
const CostingReceiverreceiver
 The planning context. More...
 
const LogicalOrderingsorderings
 The set of interesting orders. More...
 
bool aggregation_is_unordered
 Aggregation (GROUP BY and DISTINCT) do not require ordered inputs and create unordered outputs (. More...
 
int order_by_ordering_idx
 The order by which the result should be ordered (or -1 if none). More...
 
int distinct_ordering_idx
 The order by which the result should be grouped. More...
 
const Mem_root_array< SortAheadOrdering > * sort_ahead_orderings
 The orders we may sort by. More...
 
FunctionalDependencySet fd_set
 The functional dependencies that apply here. More...
 
Query_blockquery_block
 The enclosing query block. More...
 
bool need_rowid
 True if we need rowids. More...
 
const AccessPathArrayroot_candidates
 The candidate paths. More...
 

Private Member Functions

std::optional< LogicalOrderings::StateIndexDistinctOrderingState (size_t grouping_size, const SortAheadOrdering &sort_ahead_ordering) const
 Check if 'sort_ahead_ordering' is a useful order to sort by. More...
 
AccessPath MakeSortPathForDistinct (AccessPath *root_path, int ordering_idx, LogicalOrderings::StateIndex ordering_state, double output_rows) const
 Create a sort part on top of 'root_path'. More...
 
void ProposeDistinctPaths (const Bounds_checked_array< Item * > group_items, AccessPath *root_path, double output_rows, AccessPathArray *new_root_candidates) const
 Add a parent path to root_path to ensure that the output is grouped (by distinct_ordering_idx) if this is not the case already. More...
 

Detailed Description

This struct implements a builder pattern for creating paths that do DISTINCT (sort with duplicate removal) and adding them as parent of the current candidate paths (except for candidate paths that do DISTINCT already).

The struct eliminates overly long parameter lists, and makes it easy to divide the task into a set of simpler functions.

Member Function Documentation

◆ ApplyDistinct()

AccessPathArray anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::ApplyDistinct ( ) const

Create new root paths as needed to do DISTINCT.

Returns
The new root paths.

◆ DistinctOrderingState()

std::optional< LogicalOrderings::StateIndex > anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::DistinctOrderingState ( size_t  grouping_size,
const SortAheadOrdering sort_ahead_ordering 
) const
private

Check if 'sort_ahead_ordering' is a useful order to sort by.

Parameters
grouping_sizeThe size of the DISTINCT projection.
sort_ahead_orderingThe candidate ordering.
Returns
The ordering state if we should sort by this order, and an empty object otherwise.

◆ MakeSortPathForDistinct()

AccessPath anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::MakeSortPathForDistinct ( AccessPath root_path,
int  ordering_idx,
LogicalOrderings::StateIndex  ordering_state,
double  output_rows 
) const
private

Create a sort part on top of 'root_path'.

Parameters
root_pathThe path that needs sorting.
ordering_idxThe order to sort by.
ordering_stateThe ordering state of the new path.
output_rowsThe number of (distinct) output row from the new path.
Returns
The sort path.

◆ ProposeDistinctPaths()

void anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::ProposeDistinctPaths ( const Bounds_checked_array< Item * >  group_items,
AccessPath root_path,
double  output_rows,
AccessPathArray new_root_candidates 
) const
private

Add a parent path to root_path to ensure that the output is grouped (by distinct_ordering_idx) if this is not the case already.

Note that we may add multiple alternative parent paths if there are several relevant sort-ahead orders.

Parameters
group_itemsThis items we group on.
root_pathThe input path.
output_rowsThe number of (distinct) output rows.
new_root_candidatesWe add parent paths to this.

Member Data Documentation

◆ aggregation_is_unordered

bool anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::aggregation_is_unordered

Aggregation (GROUP BY and DISTINCT) do not require ordered inputs and create unordered outputs (.

See also
SecondaryEngineFlag).

◆ distinct_ordering_idx

int anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::distinct_ordering_idx

The order by which the result should be grouped.

◆ fd_set

FunctionalDependencySet anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::fd_set

The functional dependencies that apply here.

◆ need_rowid

bool anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::need_rowid

True if we need rowids.

◆ order_by_ordering_idx

int anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::order_by_ordering_idx

The order by which the result should be ordered (or -1 if none).

◆ orderings

const LogicalOrderings* anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::orderings

The set of interesting orders.

◆ query_block

Query_block* anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::query_block

The enclosing query block.

◆ receiver

const CostingReceiver* anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::receiver

The planning context.

◆ root_candidates

const AccessPathArray* anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::root_candidates

The candidate paths.

◆ sort_ahead_orderings

const Mem_root_array<SortAheadOrdering>* anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::sort_ahead_orderings

The orders we may sort by.

◆ thd

THD* anonymous_namespace{join_optimizer.cc}::ApplyDistinctParameters::thd

The current thread.


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