![]() |
MySQL 8.0.32
Source Code Documentation
|
Go to the source code of this file.
Classes | |
class | JOIN_CACHE |
Functions | |
void | filter_virtual_gcol_base_cols (const QEP_TAB *qep_tab) |
Filter the base columns of virtual generated columns if using a covering index scan. More... | |
void | add_virtual_gcol_base_cols (TABLE *table, MEM_ROOT *mem_root, MY_BITMAP *completed_read_set) |
Create a read set that undoes the work of filter_virtual_gcol_base_cols(); ie., for every virtual generated column that is part of the given table's read set, we also include the base tables. More... | |
void add_virtual_gcol_base_cols | ( | TABLE * | table, |
MEM_ROOT * | mem_root, | ||
MY_BITMAP * | completed_read_set | ||
) |
Create a read set that undoes the work of filter_virtual_gcol_base_cols(); ie., for every virtual generated column that is part of the given table's read set, we also include the base tables.
This is needed if we revert from a covering index back to a table scan (which doesn't store the virtual generated columns themselves, unlike the covering index). This happens in DynamicRangeIterator and AlternativeIterator.
The new read set gets a new buffer, allocated on the given MEM_ROOT. table->read_set is not changed.
void filter_virtual_gcol_base_cols | ( | const QEP_TAB * | qep_tab | ) |
Filter the base columns of virtual generated columns if using a covering index scan.
Adjust table->read_set so that it only contains the columns that are needed in the join operation and afterwards.
For a virtual generated column, all base columns are added to the read_set of the table. The storage engine will then copy all base column values so that the value of the GC can be calculated inside the executor. But when a virtual GC is fetched using a covering index, the actual GC value is fetched by the storage engine and the base column values are not needed. Code that looks at the read sets (join buffering, hash join, filesort) must not try to copy them. So, we eliminate from read_set those columns that are available from the covering index.
Note that some iterators (DynamicRangeIterator and AlternativeIterator) may need to switch back to table scans. If so, they will adjust the table's read set before reading; see add_virtual_gcol_base_cols().