MySQL 8.4.2
Source Code Documentation
KEY Class Reference

#include <key.h>

Public Member Functions

bool is_functional_index () const
 
bool has_records_per_key (uint key_part_no) const
 Check if records per key estimate is available for given key part. More...
 
rec_per_key_t records_per_key (uint key_part_no) const
 Retrieve an estimate for the average number of records per distinct value, when looking only at the first key_part_no+1 columns. More...
 
void set_records_per_key (uint key_part_no, rec_per_key_t rec_per_key_est)
 Set the records per key estimate for a key part. More...
 
bool supports_records_per_key () const
 Check if this key supports storing records per key information. More...
 
void set_rec_per_key_array (ulong *rec_per_key_arg, rec_per_key_t *rec_per_key_float_arg)
 Assign storage for the rec per key arrays to the KEY object. More...
 
void move_rec_per_key (ulong *rec_per_key_arg, rec_per_key_t *rec_per_key_float_arg)
 Move rec_per_key arrays from old to new position. More...
 
double in_memory_estimate () const
 Retrieve the estimate for how much of the index data that is available in a memory buffer. More...
 
void set_in_memory_estimate (double in_memory_estimate)
 Set the estimate for how much of this index that is currently in a memory buffer. More...
 

Public Attributes

uint key_length {0}
 Tot length of key. More...
 
ulong flags {0}
 dupp key and pack flags More...
 
ulong actual_flags {0}
 dupp key and pack flags for actual key parts More...
 
uint user_defined_key_parts {0}
 How many key_parts. More...
 
uint actual_key_parts {0}
 How many key_parts including hidden parts. More...
 
uint unused_key_parts {0}
 Key parts allocated for primary key parts extension but not used due to some reasons(no primary key, duplicated key parts) More...
 
uint usable_key_parts {0}
 Should normally be = actual_key_parts. More...
 
uint block_size {0}
 
bool is_algorithm_explicit {false}
 A flag which indicates that index algorithm for this key was explicitly specified by user. More...
 
plugin_ref parser {nullptr}
 Note that parser is used when the table is opened for use, and parser_name is used when the table is being created. More...
 
LEX_CSTRING parser_name {nullptr, 0}
 Fulltext [pre]parser name. More...
 
KEY_PART_INFOkey_part {nullptr}
 
const char * name {nullptr}
 Name of key. More...
 
ulong * rec_per_key {nullptr}
 Array of AVG(number of records with the same field value) for 1st ... Nth key part. More...
 
LEX_CSTRING engine_attribute {nullptr, 0}
 
LEX_CSTRING secondary_engine_attribute {nullptr, 0}
 
bool is_visible {false}
 True if this index is visible to the query optimizer. More...
 
TABLEtable {nullptr}
 
LEX_CSTRING comment {nullptr, 0}
 

Private Attributes

double m_in_memory_estimate {0.0}
 Estimate for how much of the index data that is currently available in a memory buffer. More...
 
rec_per_key_trec_per_key_float {nullptr}
 Array of AVG(number of records with the same field value) for 1st ... Nth key part. More...
 

Member Function Documentation

◆ has_records_per_key()

bool KEY::has_records_per_key ( uint  key_part_no) const
inline

Check if records per key estimate is available for given key part.

Parameters
key_part_nokey part number, must be in [0, KEY::actual_key_parts)
Returns
true if records per key estimate is available, false otherwise

◆ in_memory_estimate()

double KEY::in_memory_estimate ( ) const
inline

Retrieve the estimate for how much of the index data that is available in a memory buffer.

The returned estimate will be in the interval [0..1].

Returns
Estimate for how much of index data is available in memory buffer
Return values
IN_MEMORY_ESTIMATE_UNKNOWNno estimate available
!=IN_MEMORY_ESTIMATE_UNKNOWN estimate

◆ is_functional_index()

bool KEY::is_functional_index ( ) const
Return values
trueif this is a functional index (at least one of the key parts is a functional key part).
falseif this isn't a functional index.

◆ move_rec_per_key()

void KEY::move_rec_per_key ( ulong *  rec_per_key_arg,
rec_per_key_t rec_per_key_float_arg 
)
inline

Move rec_per_key arrays from old to new position.

Ignore if arrays have not been set up yet.

Parameters
rec_per_key_argpointer to adjusted rec per key array
rec_per_key_float_argpointer to adjusted rec per key array (float)

◆ records_per_key()

rec_per_key_t KEY::records_per_key ( uint  key_part_no) const
inline

Retrieve an estimate for the average number of records per distinct value, when looking only at the first key_part_no+1 columns.

If no record per key estimate is available for this key part, REC_PER_KEY_UNKNOWN is returned.

Parameters
key_part_nokey part number, must be in [0, KEY::actual_key_parts)
Returns
Number of records having the same key value
Return values
REC_PER_KEY_UNKNOWNno records per key estimate available
!=REC_PER_KEY_UNKNOWN record per key estimate

◆ set_in_memory_estimate()

void KEY::set_in_memory_estimate ( double  in_memory_estimate)
inline

Set the estimate for how much of this index that is currently in a memory buffer.

The estimate must be in the interval [0..1] or take the value IN_MEMORY_ESTIMATE_UNKNOWN.

◆ set_rec_per_key_array()

void KEY::set_rec_per_key_array ( ulong *  rec_per_key_arg,
rec_per_key_t rec_per_key_float_arg 
)
inline

Assign storage for the rec per key arrays to the KEY object.

This is used when allocating memory and creating KEY objects. The caller is responsible for allocating the correct size for the two arrays. If needed, the caller is also responsible for de-allocating the memory when the KEY object is no longer used.

Parameters
rec_per_key_argpointer to allocated array for storing records per key using ulong
rec_per_key_float_argpointer to allocated array for storing records per key using float

◆ set_records_per_key()

void KEY::set_records_per_key ( uint  key_part_no,
rec_per_key_t  rec_per_key_est 
)
inline

Set the records per key estimate for a key part.

The records per key estimate must be in [1.0,..> or take the value REC_PER_KEY_UNKNOWN.

Parameters
key_part_nothe number of key parts that the estimate includes, must be in [0, KEY::actual_key_parts)
rec_per_key_estnew records per key estimate

◆ supports_records_per_key()

bool KEY::supports_records_per_key ( ) const
inline

Check if this key supports storing records per key information.

Returns
true if it has support for storing records per key information, false otherwise.

Member Data Documentation

◆ actual_flags

ulong KEY::actual_flags {0}

dupp key and pack flags for actual key parts

◆ actual_key_parts

uint KEY::actual_key_parts {0}

How many key_parts including hidden parts.

◆ block_size

uint KEY::block_size {0}

◆ comment

LEX_CSTRING KEY::comment {nullptr, 0}

◆ engine_attribute

LEX_CSTRING KEY::engine_attribute {nullptr, 0}

◆ flags

ulong KEY::flags {0}

dupp key and pack flags

◆ is_algorithm_explicit

bool KEY::is_algorithm_explicit {false}

A flag which indicates that index algorithm for this key was explicitly specified by user.

So, for example, it should be mentioned in SHOW CREATE TABLE output.

◆ is_visible

bool KEY::is_visible {false}

True if this index is visible to the query optimizer.

The optimizer may only use visible indexes.

◆ key_length

uint KEY::key_length {0}

Tot length of key.

◆ key_part

KEY_PART_INFO* KEY::key_part {nullptr}

◆ m_in_memory_estimate

double KEY::m_in_memory_estimate {0.0}
private

Estimate for how much of the index data that is currently available in a memory buffer.

Valid range is [0..1]. This will be initialized to a IN_MEMORY_ESTIMATE_UNKNOWN. If it still has this value when used, it means that the storage engine has not supplied a value.

◆ name

const char* KEY::name {nullptr}

Name of key.

◆ parser

plugin_ref KEY::parser {nullptr}

Note that parser is used when the table is opened for use, and parser_name is used when the table is being created.

Fulltext [pre]parser

◆ parser_name

LEX_CSTRING KEY::parser_name {nullptr, 0}

Fulltext [pre]parser name.

◆ rec_per_key

ulong* KEY::rec_per_key {nullptr}

Array of AVG(number of records with the same field value) for 1st ... Nth key part.

0 means 'not known'. For internally created temporary tables, this member can be nullptr.

◆ rec_per_key_float

rec_per_key_t* KEY::rec_per_key_float {nullptr}
private

Array of AVG(number of records with the same field value) for 1st ... Nth key part.

For internally created temporary tables, this member can be nullptr. This is the same information as stored in the above rec_per_key array but using float values instead of integer values. If the storage engine has supplied values in this array, these will be used. Otherwise the value in rec_per_key will be used.

◆ secondary_engine_attribute

LEX_CSTRING KEY::secondary_engine_attribute {nullptr, 0}

◆ table

TABLE* KEY::table {nullptr}

◆ unused_key_parts

uint KEY::unused_key_parts {0}

Key parts allocated for primary key parts extension but not used due to some reasons(no primary key, duplicated key parts)

◆ usable_key_parts

uint KEY::usable_key_parts {0}

Should normally be = actual_key_parts.

◆ user_defined_key_parts

uint KEY::user_defined_key_parts {0}

How many key_parts.


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