MySQL 8.3.0
Source Code Documentation
group_index_skip_scan_plan.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2023, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef SQL_RANGE_OPTIMIZER_GROUP_INDEX_SKIP_SCAN_PLAN_H_
24#define SQL_RANGE_OPTIMIZER_GROUP_INDEX_SKIP_SCAN_PLAN_H_
25
26#include <sys/types.h>
27
28#include "my_base.h"
29#include "my_inttypes.h"
31#include "sql/sql_const.h"
32
33class KEY;
34class KEY_PART_INFO;
36class RANGE_OPT_PARAM;
37class SEL_ROOT;
38class SEL_TREE;
39
40/*
41 Plan for a GroupIndexSkipScanIterator scan.
42*/
43
47 /**
48 true if there is an aggregate distinct function, e.g.
49 "COUNT(DISTINCT x)"
50 */
52 /**
53 The key_part of the only field used by all MIN/MAX functions.
54 Note that GROUP_INDEX_SKIP_SCAN is not used if there are MIN/MAX
55 functions on more than one field.
56 */
58 uint group_prefix_len; ///< Length of all key parts in the group prefix
59 uint group_key_parts; ///< Number of index key parts in the group prefix
60 KEY *index_info; ///< The index chosen for data access
61 uint key_infix_len; ///< Longest key for equality predicates
62 SEL_ROOT *index_tree; ///< The sub-tree corresponding to index_info
63 bool is_index_scan; ///< Use index_next() instead of random read
70};
71
72/* Info required to create a group index skip scan AccessPath
73 */
75 Cost_estimate cost; /* Cost of scan */
76 ha_rows records; /* Number of rows returned by scan */
77 uint param_idx; /* Location of index in param->keys */
78 uint num_used_key_parts; /* Number of index key parts used for access. */
79 ha_rows quick_prefix_records; /* Number of records returned by index range
80 scan used internally if any */
81 Item_field *min_max_arg_item; /* The argument of all MIN/MAX functions */
83 *param; /* Part of the access path - used in creation of the Iterator for
84 this scan. */
85};
86
88 THD *thd, RANGE_OPT_PARAM *param, SEL_TREE *tree,
89 enum_order order_direction, bool skip_records_in_range, double cost_est);
90
92 SEL_TREE *tree, enum_order order_direction,
93 bool skip_records_in_range,
94 double cost_est);
95
97 const RANGE_OPT_PARAM *,
98 Opt_trace_object *trace_object);
99
100void dbug_dump_group_index_skip_scan(int indent, bool verbose,
101 const AccessPath *path);
102
103#endif // SQL_RANGE_OPTIMIZER_GROUP_INDEX_SKIP_SCAN_PLAN_H_
Used to store optimizer cost estimates.
Definition: handler.h:3840
Definition: item.h:4340
Definition: key.h:56
Definition: key.h:112
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:425
A JSON object (unordered set of key/value pairs).
Definition: opt_trace.h:801
Definition: range_opt_param.h:28
A graph of (possible multiple) key ranges, represented as a red-black binary tree.
Definition: tree.h:67
Definition: tree.h:870
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
void trace_basic_info_group_index_skip_scan(THD *thd, const AccessPath *path, const RANGE_OPT_PARAM *, Opt_trace_object *trace_object)
Definition: group_index_skip_scan_plan.cc:78
Mem_root_array< AccessPath * > get_all_group_skip_scans(THD *thd, RANGE_OPT_PARAM *param, SEL_TREE *tree, enum_order order_direction, bool skip_records_in_range, double cost_est)
Test if group index skip scan is applicable and if so, construct a new AccessPath for every candidate...
Definition: group_index_skip_scan_plan.cc:910
void dbug_dump_group_index_skip_scan(int indent, bool verbose, const AccessPath *path)
Definition: group_index_skip_scan_plan.cc:1836
AccessPath * get_best_group_skip_scan(THD *thd, RANGE_OPT_PARAM *param, SEL_TREE *tree, enum_order order_direction, bool skip_records_in_range, double cost_est)
Test if this access method is applicable to a GROUP query with MIN/MAX functions, and if so,...
Definition: group_index_skip_scan_plan.cc:300
enum_order
Definition: key_spec.h:64
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1140
Some integer typedefs for easier portability.
static uint verbose
Definition: mysqlcheck.cc:65
static char * path
Definition: mysqldump.cc:148
File containing constants that can be used throughout the server.
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:212
Definition: group_index_skip_scan_plan.h:74
uint param_idx
Definition: group_index_skip_scan_plan.h:77
GroupIndexSkipScanParameters * param
Definition: group_index_skip_scan_plan.h:83
Cost_estimate cost
Definition: group_index_skip_scan_plan.h:75
ha_rows records
Definition: group_index_skip_scan_plan.h:76
uint num_used_key_parts
Definition: group_index_skip_scan_plan.h:78
ha_rows quick_prefix_records
Definition: group_index_skip_scan_plan.h:79
Item_field * min_max_arg_item
Definition: group_index_skip_scan_plan.h:81
Definition: group_index_skip_scan_plan.h:44
Quick_ranges_array key_infix_ranges
Definition: group_index_skip_scan_plan.h:68
uint group_key_parts
Number of index key parts in the group prefix.
Definition: group_index_skip_scan_plan.h:59
Mem_root_array< Item_sum * > max_functions
Definition: group_index_skip_scan_plan.h:46
uint real_key_parts
Definition: group_index_skip_scan_plan.h:65
Mem_root_array< Item_sum * > min_functions
Definition: group_index_skip_scan_plan.h:45
uint group_prefix_len
Length of all key parts in the group prefix.
Definition: group_index_skip_scan_plan.h:58
SEL_ROOT * index_tree
The sub-tree corresponding to index_info.
Definition: group_index_skip_scan_plan.h:62
bool have_agg_distinct
true if there is an aggregate distinct function, e.g.
Definition: group_index_skip_scan_plan.h:51
uint max_used_key_length
Definition: group_index_skip_scan_plan.h:66
uint key_infix_len
Longest key for equality predicates.
Definition: group_index_skip_scan_plan.h:61
Quick_ranges prefix_ranges
Definition: group_index_skip_scan_plan.h:67
KEY_PART * used_key_part
Definition: group_index_skip_scan_plan.h:64
bool is_index_scan
Use index_next() instead of random read.
Definition: group_index_skip_scan_plan.h:63
Quick_ranges min_max_ranges
Definition: group_index_skip_scan_plan.h:69
KEY_PART_INFO * min_max_arg_part
The key_part of the only field used by all MIN/MAX functions.
Definition: group_index_skip_scan_plan.h:57
KEY * index_info
The index chosen for data access.
Definition: group_index_skip_scan_plan.h:60
Definition: range_optimizer.h:54