MySQL 8.0.40
Source Code Documentation
|
#include <tree.h>
Public Types | |
enum | Type { IMPOSSIBLE , ALWAYS , KEY } |
Starting an effort to document this field: More... | |
Public Member Functions | |
SEL_TREE (enum Type type_arg, MEM_ROOT *root, size_t num_keys) | |
SEL_TREE (MEM_ROOT *root, size_t num_keys) | |
SEL_TREE (SEL_TREE *arg, RANGE_OPT_PARAM *param) | |
Constructor that performs deep-copy of the SEL_ARG trees in 'keys[]' and the index merge alternatives in 'merges'. More... | |
SEL_ROOT * | release_key (int index) |
Convenience function for removing an element in keys[]. More... | |
void | set_key (int index, SEL_ROOT *key) |
Convenience function for changing an element in keys[], including updating the use_count. More... | |
Public Attributes | |
enum SEL_TREE::Type | type |
bool | inexact = false |
Whether this SEL_TREE is an inexact (too broad) representation of the predicates it is based on; that is, if it does not necessarily subsume all of them. More... | |
Mem_root_array< SEL_ROOT * > | keys |
Key_map | keys_map |
List< SEL_IMERGE > | merges |
Key_map | ror_scans_map |
uint | n_ror_scans |
ROR_SCAN_INFO ** | ror_scans |
ROR_SCAN_INFO ** | ror_scans_end |
enum SEL_TREE::Type |
Starting an effort to document this field:
IMPOSSIBLE: if keys[i]->type == SEL_ROOT::Type::IMPOSSIBLE for some i, then type == SEL_TREE::IMPOSSIBLE. Rationale: if the predicate for one of the indexes is always false, then the full predicate is also always false.
ALWAYS: if either (keys[i]->is_always()) or (keys[i] == NULL) for all i, then type == SEL_TREE::ALWAYS. Rationale: the range access method will not be able to filter out any rows when there are no range predicates that can be used to filter on any index.
KEY: There are range predicates that can be used on at least one index.
Enumerator | |
---|---|
IMPOSSIBLE | |
ALWAYS | |
KEY |
|
inline |
SEL_TREE::SEL_TREE | ( | SEL_TREE * | arg, |
RANGE_OPT_PARAM * | param | ||
) |
Constructor that performs deep-copy of the SEL_ARG trees in 'keys[]' and the index merge alternatives in 'merges'.
arg | The SEL_TREE to copy |
param | Parameters for range analysis |
|
inline |
Convenience function for removing an element in keys[].
The typical use for this function is to disconnect the next_key_part from the root, send it to key_and() or key_or(), and then connect the result of that function back to the SEL_ROOT using set_key().
index | Which index slot to release. |
|
inline |
Convenience function for changing an element in keys[], including updating the use_count.
index | Which index slot to change. |
key | The new contents of the index slot. Is allowed to be nullptr. |
bool SEL_TREE::inexact = false |
Whether this SEL_TREE is an inexact (too broad) representation of the predicates it is based on; that is, if it does not necessarily subsume all of them.
Note that a nullptr return from get_mm_tree() (which means “could not generate a tree from this predicate”) is by definition inexact.
There are two main ways a SEL_TREE can become inexact:
If a SEL_TREE is inexact, the predicates must be rechecked after the range scan, using a filter. (Note that it is never too narrow, only ever exact or too broad.) The old join optimizer always does this, no matter what the inexact flag is set to.
Note that additional checks are needed to subsume a predicate even if inexact == false. In particular, SEL_TREE contains information for all indexes over a table, but if a regular range scan is chosen, it can use only one index. So one must then go through all predicates to see if they refer to fields not contained in the given index. Furthermore, range scans on composite (multi-part) indexes can drop predicates on the later keyparts (making predicates on those keyparts inexact), since range scans only support inequalities on the last keypart in any given range. This check must be done in get_ranges_from_tree().
Mem_root_array<SEL_ROOT *> SEL_TREE::keys |
Key_map SEL_TREE::keys_map |
List<SEL_IMERGE> SEL_TREE::merges |
uint SEL_TREE::n_ror_scans |
ROR_SCAN_INFO** SEL_TREE::ror_scans |
ROR_SCAN_INFO** SEL_TREE::ror_scans_end |
Key_map SEL_TREE::ror_scans_map |
enum SEL_TREE::Type SEL_TREE::type |