MySQL 9.0.0
Source Code Documentation
SEL_TREE Class Reference

#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_ROOTrelease_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_IMERGEmerges
 
Key_map ror_scans_map
 
uint n_ror_scans
 

Member Enumeration Documentation

◆ 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 

Constructor & Destructor Documentation

◆ SEL_TREE() [1/3]

SEL_TREE::SEL_TREE ( enum Type  type_arg,
MEM_ROOT root,
size_t  num_keys 
)
inline

◆ SEL_TREE() [2/3]

SEL_TREE::SEL_TREE ( MEM_ROOT root,
size_t  num_keys 
)
inline

◆ SEL_TREE() [3/3]

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'.

Parameters
argThe SEL_TREE to copy
paramParameters for range analysis

Member Function Documentation

◆ release_key()

SEL_ROOT * SEL_TREE::release_key ( int  index)
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().

Parameters
indexWhich index slot to release.
Returns
The value in the slot (before removal).

◆ set_key()

void SEL_TREE::set_key ( int  index,
SEL_ROOT key 
)
inline

Convenience function for changing an element in keys[], including updating the use_count.

Parameters
indexWhich index slot to change.
keyThe new contents of the index slot. Is allowed to be nullptr.

Member Data Documentation

◆ inexact

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:

  • The predicate references fields not contained in any indexes tracked by the SEL_TREE.
  • The predicate could be of a form that is not representable as a range. E.g., x > 30 is a range, x mod 2 = 1 is not (although it could in theory be converted to a large amount of disjunct ranges).

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().

◆ keys

Mem_root_array<SEL_ROOT *> SEL_TREE::keys

◆ keys_map

Key_map SEL_TREE::keys_map

◆ merges

List<SEL_IMERGE> SEL_TREE::merges

◆ n_ror_scans

uint SEL_TREE::n_ror_scans

◆ ror_scans_map

Key_map SEL_TREE::ror_scans_map

◆ type

enum SEL_TREE::Type SEL_TREE::type

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