MySQL 9.1.0
Source Code Documentation
|
#include "sql/range_optimizer/rowid_ordered_retrieval_plan.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <utility>
#include "m_string.h"
#include "my_alloc.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "mysql/strings/m_ctype.h"
#include "sql/key.h"
#include "sql/key_spec.h"
#include "sql/mem_root_array.h"
#include "sql/opt_costmodel.h"
#include "sql/opt_hints.h"
#include "sql/opt_trace.h"
#include "sql/range_optimizer/index_range_scan.h"
#include "sql/range_optimizer/index_range_scan_plan.h"
#include "sql/range_optimizer/internal.h"
#include "sql/range_optimizer/path_helpers.h"
#include "sql/range_optimizer/range_opt_param.h"
#include "sql/range_optimizer/rowid_ordered_retrieval.h"
#include "sql/range_optimizer/tree.h"
#include "sql/sql_bitmap.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_lex.h"
#include "sql/sql_optimizer.h"
#include "sql/table.h"
#include "sql_string.h"
Functions | |
static void | print_ror_scans (TABLE *table, const char *msg, const Mem_root_array< ROR_SCAN_INFO * > &ror_scans) |
OverflowBitset | get_needed_fields (const RANGE_OPT_PARAM *param) |
void | trace_basic_info_rowid_intersection (THD *thd, const AccessPath *path, const RANGE_OPT_PARAM *param, Opt_trace_object *trace_object) |
void | trace_basic_info_rowid_union (THD *thd, const AccessPath *path, const RANGE_OPT_PARAM *param, Opt_trace_object *trace_object) |
ROR_SCAN_INFO * | make_ror_scan (const RANGE_OPT_PARAM *param, int idx, SEL_ROOT *sel_root, OverflowBitset needed_fields) |
void | find_intersect_order (Mem_root_array< ROR_SCAN_INFO * > *ror_scans, OverflowBitset needed_fields, MEM_ROOT *mem_root) |
Sort indexes in an order that is likely to be a good index merge intersection order. More... | |
AccessPath * | MakeRowIdOrderedIndexScanAccessPath (ROR_SCAN_INFO *scan, TABLE *table, KEY_PART *used_key_part, bool reuse_handler, MEM_ROOT *mem_root) |
AccessPath * | get_best_ror_intersect (THD *thd, const RANGE_OPT_PARAM *param, TABLE *table, bool index_merge_intersect_allowed, SEL_TREE *tree, double cost_est, bool force_index_merge_result, bool reuse_handler) |
static int | find_max_used_key_length (const AccessPath *scan) |
void | add_keys_and_lengths_rowid_intersection (const AccessPath *path, String *key_names, String *used_lengths) |
void | add_keys_and_lengths_rowid_union (const AccessPath *path, String *key_names, String *used_lengths) |
void | dbug_dump_rowid_intersection (int indent, bool verbose, const Mem_root_array< AccessPath * > &children) |
void | dbug_dump_rowid_union (int indent, bool verbose, const Mem_root_array< AccessPath * > &children) |
void add_keys_and_lengths_rowid_intersection | ( | const AccessPath * | path, |
String * | key_names, | ||
String * | used_lengths | ||
) |
void add_keys_and_lengths_rowid_union | ( | const AccessPath * | path, |
String * | key_names, | ||
String * | used_lengths | ||
) |
void dbug_dump_rowid_intersection | ( | int | indent, |
bool | verbose, | ||
const Mem_root_array< AccessPath * > & | children | ||
) |
void dbug_dump_rowid_union | ( | int | indent, |
bool | verbose, | ||
const Mem_root_array< AccessPath * > & | children | ||
) |
void find_intersect_order | ( | Mem_root_array< ROR_SCAN_INFO * > * | ror_scans, |
OverflowBitset | needed_fields, | ||
MEM_ROOT * | mem_root | ||
) |
Sort indexes in an order that is likely to be a good index merge intersection order.
After running this function ror_scans are ordered according to this strategy:
1) Minimize the number of indexes that must be used in the intersection. I.e., the index covering most fields not already covered by other indexes earlier in the sort order is picked first. 2) When multiple indexes cover equally many uncovered fields, the index with lowest E(Number of rows) is chosen.
Note that all permutations of index ordering are not tested, so this function may not find the optimal order.
[in,out] | ror_scans | ror scans to be used in index merge intersection |
needed_fields | Bitmask of fields needed by the query. | |
mem_root | memory root to be used. |
|
static |
AccessPath * get_best_ror_intersect | ( | THD * | thd, |
const RANGE_OPT_PARAM * | param, | ||
TABLE * | table, | ||
bool | index_merge_intersect_allowed, | ||
SEL_TREE * | tree, | ||
double | cost_est, | ||
bool | force_index_merge_result, | ||
bool | reuse_handler | ||
) |
OverflowBitset get_needed_fields | ( | const RANGE_OPT_PARAM * | param | ) |
ROR_SCAN_INFO * make_ror_scan | ( | const RANGE_OPT_PARAM * | param, |
int | idx, | ||
SEL_ROOT * | sel_root, | ||
OverflowBitset | needed_fields | ||
) |
AccessPath * MakeRowIdOrderedIndexScanAccessPath | ( | ROR_SCAN_INFO * | scan, |
TABLE * | table, | ||
KEY_PART * | used_key_part, | ||
bool | reuse_handler, | ||
MEM_ROOT * | mem_root | ||
) |
|
static |
void trace_basic_info_rowid_intersection | ( | THD * | thd, |
const AccessPath * | path, | ||
const RANGE_OPT_PARAM * | param, | ||
Opt_trace_object * | trace_object | ||
) |
void trace_basic_info_rowid_union | ( | THD * | thd, |
const AccessPath * | path, | ||
const RANGE_OPT_PARAM * | param, | ||
Opt_trace_object * | trace_object | ||
) |