MySQL 9.0.0
Source Code Documentation
group_index_skip_scan_plan.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef SQL_RANGE_OPTIMIZER_GROUP_INDEX_SKIP_SCAN_PLAN_H_
25#define SQL_RANGE_OPTIMIZER_GROUP_INDEX_SKIP_SCAN_PLAN_H_
26
27#include <sys/types.h>
28
29#include "my_base.h"
30#include "my_inttypes.h"
32#include "sql/sql_const.h"
33
34class KEY;
35class KEY_PART_INFO;
37class RANGE_OPT_PARAM;
38class SEL_ROOT;
39class SEL_TREE;
40
41/*
42 Plan for a GroupIndexSkipScanIterator scan.
43*/
44
48 /**
49 true if there is an aggregate distinct function, e.g.
50 "COUNT(DISTINCT x)"
51 */
53 /**
54 The key_part of the only field used by all MIN/MAX functions.
55 Note that GROUP_INDEX_SKIP_SCAN is not used if there are MIN/MAX
56 functions on more than one field.
57 */
59 uint group_prefix_len; ///< Length of all key parts in the group prefix
60 uint group_key_parts; ///< Number of index key parts in the group prefix
61 KEY *index_info; ///< The index chosen for data access
62 uint key_infix_len; ///< Longest key for equality predicates
63 SEL_ROOT *index_tree; ///< The sub-tree corresponding to index_info
64 bool is_index_scan; ///< Use index_next() instead of random read
71};
72
73/* Info required to create a group index skip scan AccessPath
74 */
76 Cost_estimate cost; /* Cost of scan */
77 ha_rows records; /* Number of rows returned by scan */
78 uint param_idx; /* Location of index in param->keys */
79 uint num_used_key_parts; /* Number of index key parts used for access. */
80 ha_rows quick_prefix_records; /* Number of records returned by index range
81 scan used internally if any */
82 Item_field *min_max_arg_item; /* The argument of all MIN/MAX functions */
84 *param; /* Part of the access path - used in creation of the Iterator for
85 this scan. */
86};
87
89 THD *thd, RANGE_OPT_PARAM *param, SEL_TREE *tree,
90 enum_order order_direction, bool skip_records_in_range, double cost_est);
91
93 SEL_TREE *tree, enum_order order_direction,
94 bool skip_records_in_range,
95 double cost_est);
96
98 const RANGE_OPT_PARAM *,
99 Opt_trace_object *trace_object);
100
101void dbug_dump_group_index_skip_scan(int indent, bool verbose,
102 const AccessPath *path);
103
104#endif // SQL_RANGE_OPTIMIZER_GROUP_INDEX_SKIP_SCAN_PLAN_H_
Used to store optimizer cost estimates.
Definition: handler.h:3865
Definition: item.h:4370
Definition: key.h:57
Definition: key.h:113
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
A JSON object (unordered set of key/value pairs).
Definition: opt_trace.h:802
Definition: range_opt_param.h:29
A graph of (possible multiple) key ranges, represented as a red-black binary tree.
Definition: tree.h:68
Definition: tree.h:871
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
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:79
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:911
void dbug_dump_group_index_skip_scan(int indent, bool verbose, const AccessPath *path)
Definition: group_index_skip_scan_plan.cc:1837
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:301
enum_order
Definition: key_spec.h:65
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1141
Some integer typedefs for easier portability.
static uint verbose
Definition: mysqlcheck.cc:66
static char * path
Definition: mysqldump.cc:149
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:213
Definition: group_index_skip_scan_plan.h:75
uint param_idx
Definition: group_index_skip_scan_plan.h:78
GroupIndexSkipScanParameters * param
Definition: group_index_skip_scan_plan.h:84
Cost_estimate cost
Definition: group_index_skip_scan_plan.h:76
ha_rows records
Definition: group_index_skip_scan_plan.h:77
uint num_used_key_parts
Definition: group_index_skip_scan_plan.h:79
ha_rows quick_prefix_records
Definition: group_index_skip_scan_plan.h:80
Item_field * min_max_arg_item
Definition: group_index_skip_scan_plan.h:82
Definition: group_index_skip_scan_plan.h:45
Quick_ranges_array key_infix_ranges
Definition: group_index_skip_scan_plan.h:69
uint group_key_parts
Number of index key parts in the group prefix.
Definition: group_index_skip_scan_plan.h:60
Mem_root_array< Item_sum * > max_functions
Definition: group_index_skip_scan_plan.h:47
uint real_key_parts
Definition: group_index_skip_scan_plan.h:66
Mem_root_array< Item_sum * > min_functions
Definition: group_index_skip_scan_plan.h:46
uint group_prefix_len
Length of all key parts in the group prefix.
Definition: group_index_skip_scan_plan.h:59
SEL_ROOT * index_tree
The sub-tree corresponding to index_info.
Definition: group_index_skip_scan_plan.h:63
bool have_agg_distinct
true if there is an aggregate distinct function, e.g.
Definition: group_index_skip_scan_plan.h:52
uint max_used_key_length
Definition: group_index_skip_scan_plan.h:67
uint key_infix_len
Longest key for equality predicates.
Definition: group_index_skip_scan_plan.h:62
Quick_ranges prefix_ranges
Definition: group_index_skip_scan_plan.h:68
KEY_PART * used_key_part
Definition: group_index_skip_scan_plan.h:65
bool is_index_scan
Use index_next() instead of random read.
Definition: group_index_skip_scan_plan.h:64
Quick_ranges min_max_ranges
Definition: group_index_skip_scan_plan.h:70
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:58
KEY * index_info
The index chosen for data access.
Definition: group_index_skip_scan_plan.h:61
Definition: range_optimizer.h:55