MySQL 9.1.0
Source Code Documentation
|
#include <index_skip_scan.h>
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 IteratorProfiler * | GetProfiler () const |
Get profiling data for this iterator (for 'EXPLAIN ANALYZE'). More... | |
virtual void | SetOverrideProfiler (const IteratorProfiler *profiler) |
virtual RowIterator * | real_iterator () |
If this iterator is wrapping a different iterator (e.g. More... | |
virtual const RowIterator * | real_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 |
KEY * | index_info |
MY_BITMAP | column_bitmap |
const uint | eq_prefix_len |
uint | eq_prefix_key_parts |
EQPrefix * | eq_prefixes |
uchar * | eq_prefix |
uint | max_used_key_length |
uint | used_key_parts |
uchar * | distinct_prefix |
uint | distinct_prefix_len |
uint | distinct_prefix_key_parts |
MEM_ROOT * | mem_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) |
TABLE * | table () const |
Protected Member Functions inherited from RowIterator | |
THD * | thd () const |
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
|
override |
|
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.
|
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.
|
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.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |