MySQL 8.0.40
Source Code Documentation
IndexSkipScanIterator Class Reference

#include <index_skip_scan.h>

Inheritance diagram for IndexSkipScanIterator:
[legend]

Public Member Functions

 IndexSkipScanIterator (THD *thd, TABLE *table, KEY *index_info, uint index, uint eq_prefix_len, uint eq_prefix_key_parts, EQPrefix *eq_prefixes, uint used_key_parts, MEM_ROOT *temp_mem_root, bool has_aggregate_function, uchar *min_range_key, uchar *max_range_key, uchar *min_search_key, uchar *max_search_key, uint range_cond_flag, uint range_key_len)
 Construct new quick select for queries that can do skip scans. More...
 
 ~IndexSkipScanIterator () override
 
bool Init () override
 Initialize or reinitialize the iterator. More...
 
int Read () override
 Get the next row for skip scan. More...
 
- Public Member Functions inherited from TableRowIterator
 TableRowIterator (THD *thd, TABLE *table)
 
void UnlockRow () override
 The default implementation of unlock-row method of RowIterator, used in all access methods except EQRefIterator. More...
 
void SetNullRowFlag (bool is_null_row) override
 Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag is true, you'll get only NULLs no matter what is actually in the buffer (typically some old leftover row). More...
 
void StartPSIBatchMode () override
 Start performance schema batch mode, if supported (otherwise ignored). More...
 
void EndPSIBatchModeIfStarted () override
 Ends performance schema batch mode, if started. More...
 
- Public Member Functions inherited from RowIterator
 RowIterator (THD *thd)
 
virtual ~RowIterator ()=default
 
 RowIterator (const RowIterator &)=delete
 
 RowIterator (RowIterator &&)=default
 
virtual const IteratorProfilerGetProfiler () const
 Get profiling data for this iterator (for 'EXPLAIN ANALYZE'). More...
 
virtual void SetOverrideProfiler (const IteratorProfiler *profiler)
 
virtual RowIteratorreal_iterator ()
 If this iterator is wrapping a different iterator (e.g. More...
 
virtual const RowIteratorreal_iterator () const
 

Private Member Functions

bool next_eq_prefix ()
 Increments cur_prefix and sets what the next equality prefix should be. More...
 

Private Attributes

uint index
 
KEYindex_info
 
MY_BITMAP column_bitmap
 
const uint eq_prefix_len
 
uint eq_prefix_key_parts
 
EQPrefixeq_prefixes
 
uchareq_prefix
 
uint max_used_key_length
 
uint used_key_parts
 
uchardistinct_prefix
 
uint distinct_prefix_len
 
uint distinct_prefix_key_parts
 
MEM_ROOTmem_root
 
const uint range_key_len
 
bool seen_first_key
 
uchar *const min_range_key
 
uchar *const max_range_key
 
uchar *const min_search_key
 
uchar *const max_search_key
 
const uint range_cond_flag
 
key_range start_key
 
key_range end_key
 
bool has_aggregate_function
 

Additional Inherited Members

- Protected Member Functions inherited from TableRowIterator
int HandleError (int error)
 
void PrintError (int error)
 
TABLEtable () const
 
- Protected Member Functions inherited from RowIterator
THDthd () const
 

Constructor & Destructor Documentation

◆ IndexSkipScanIterator()

IndexSkipScanIterator::IndexSkipScanIterator ( THD thd,
TABLE table_arg,
KEY index_info,
uint  use_index,
uint  eq_prefix_len,
uint  eq_prefix_key_parts,
EQPrefix eq_prefixes,
uint  used_key_parts_arg,
MEM_ROOT return_mem_root,
bool  has_aggregate_function,
uchar min_range_key_arg,
uchar max_range_key_arg,
uchar min_search_key_arg,
uchar max_search_key_arg,
uint  range_cond_flag_arg,
uint  range_key_len_arg 
)

Construct new quick select for queries that can do skip scans.

See get_best_skip_scan() description for more details.

SYNOPSIS IndexSkipScanIterator::IndexSkipScanIterator() table The table being accessed index_info The index chosen for data access use_index The id of index_info range_part The keypart belonging to the range condition C index_range_tree The complete range key eq_prefix_len Length of the equality prefix key eq_prefix_key_parts Number of keyparts in the equality prefix eq_prefixes Array of equality constants (IN list) used_key_parts_arg Total number of keyparts A_1,...,C read_cost_arg Cost of this access method read_records Number of records returned return_mem_root Memory pool for this class

RETURN None

◆ ~IndexSkipScanIterator()

IndexSkipScanIterator::~IndexSkipScanIterator ( )
override

Member Function Documentation

◆ Init()

bool IndexSkipScanIterator::Init ( )
overridevirtual

Initialize or reinitialize the iterator.

You must always call Init() before trying a Read() (but Init() does not imply Read()).

You can call Init() multiple times; subsequent calls will rewind the iterator (or reposition it, depending on whether the iterator takes in e.g. a Index_lookup) and allow you to read the records anew.

Implements RowIterator.

◆ next_eq_prefix()

bool IndexSkipScanIterator::next_eq_prefix ( )
private

Increments cur_prefix and sets what the next equality prefix should be.

SYNOPSIS IndexSkipScanIterator::next_eq_prefix()

DESCRIPTION Increments cur_prefix and sets what the next equality prefix should be. This is done in index order, so the increment happens on the last keypart. The key is written to eq_prefix.

RETURN true OK false No more equality key prefixes.

◆ Read()

int IndexSkipScanIterator::Read ( )
overridevirtual

Get the next row for skip scan.

SYNOPSIS IndexSkipScanIterator::Read()

DESCRIPTION Find the next record in the skip scan. The scan is broken into groups based on distinct A_1,...,B_m. The strategy is to have an outer loop going through all possible A_1,...,A_k. This work is done in next_eq_prefix().

For each equality prefix that we get from "next_eq_prefix() we loop through all distinct B_1,...,B_m within that prefix. And for each of those groups we do a subrange scan on keypart C.

The high level algorithm is like so: for (eq_prefix in eq_prefixes) // (A_1,....A_k) for (distinct_prefix in eq_prefix) // A_1-B_1,...,A_k-B_m do subrange scan within distinct prefix using range_cond // A_1-B_1-C,...A_k-B_m-C

But since this is a iterator interface, state needs to be kept between calls. State is stored in eq_prefix, cur_eq_prefix and distinct_prefix.

NOTES We can be more memory efficient by combining some of these fields. For example, eq_prefix will always be a prefix of distinct_prefix, and distinct_prefix will always be a prefix of min_search_key/max_search_key.

RETURN See RowIterator::Read()

Implements RowIterator.

Member Data Documentation

◆ column_bitmap

MY_BITMAP IndexSkipScanIterator::column_bitmap
private

◆ distinct_prefix

uchar* IndexSkipScanIterator::distinct_prefix
private

◆ distinct_prefix_key_parts

uint IndexSkipScanIterator::distinct_prefix_key_parts
private

◆ distinct_prefix_len

uint IndexSkipScanIterator::distinct_prefix_len
private

◆ end_key

key_range IndexSkipScanIterator::end_key
private

◆ eq_prefix

uchar* IndexSkipScanIterator::eq_prefix
private

◆ eq_prefix_key_parts

uint IndexSkipScanIterator::eq_prefix_key_parts
private

◆ eq_prefix_len

const uint IndexSkipScanIterator::eq_prefix_len
private

◆ eq_prefixes

EQPrefix* IndexSkipScanIterator::eq_prefixes
private

◆ has_aggregate_function

bool IndexSkipScanIterator::has_aggregate_function
private

◆ index

uint IndexSkipScanIterator::index
private

◆ index_info

KEY* IndexSkipScanIterator::index_info
private

◆ max_range_key

uchar* const IndexSkipScanIterator::max_range_key
private

◆ max_search_key

uchar* const IndexSkipScanIterator::max_search_key
private

◆ max_used_key_length

uint IndexSkipScanIterator::max_used_key_length
private

◆ mem_root

MEM_ROOT* IndexSkipScanIterator::mem_root
private

◆ min_range_key

uchar* const IndexSkipScanIterator::min_range_key
private

◆ min_search_key

uchar* const IndexSkipScanIterator::min_search_key
private

◆ range_cond_flag

const uint IndexSkipScanIterator::range_cond_flag
private

◆ range_key_len

const uint IndexSkipScanIterator::range_key_len
private

◆ seen_first_key

bool IndexSkipScanIterator::seen_first_key
private

◆ start_key

key_range IndexSkipScanIterator::start_key
private

◆ used_key_parts

uint IndexSkipScanIterator::used_key_parts
private

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