MySQL 9.1.0
Source Code Documentation
explain_access_path.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 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_JOIN_OPTIMIZER_EXPLAIN_ACCESS_PATH_H
25#define SQL_JOIN_OPTIMIZER_EXPLAIN_ACCESS_PATH_H
26
27#include <string>
28
29struct AccessPath;
31class JOIN;
32class THD;
33
34/// Print out an access path and all of its children (if any) in a tree.
35std::string PrintQueryPlan(THD *ethd, const THD *query_thd,
36 Query_expression *unit);
37/// For debugging purposes.
38std::string PrintQueryPlan(int level, AccessPath *path, JOIN *join,
39 bool is_root_of_join);
40
41/**
42 Generate a digest based on the subplan that the given access path
43 represents. This can be used by developers to force a given subplan,
44 to investigate e.g. whether a given choice is actually faster in practice,
45 force-apply a plan from the old join optimizer (or at least the types of
46 subplans that are ever considered; e.g. aggregation through temporary
47 tables are not) into the hypergraph join optimizer (to see how it's costed),
48 or whether a given plan is even generated. If DEBUG contains
49 force_subplan_0x<token>, subplans with the given token are unconditionally
50 preferred over all others.
51
52 The token returned is “0x@<digest@>”, where @<digest@> is the first 64 bits
53 of the SHA-256 sum of this string:
54
55 desc1,desc2,...,[child1_desc:]0xchild1,[child2_desc:]0xchild2,@<more
56 children@>
57
58 where desc1, desc2, etc. are the description lines given by EXPLAIN,
59 and 0xchild1 is the token for children. The normal way to generate such
60 tokens is to use SET DEBUG='+d,subplan_tokens' and look at the EXPLAIN
61 FORMAT=tree, but in a pinch, you can also write them by hand and use
62 sha256sum or a similar tool.
63
64 Only the hypergraph join optimizer honors token preferences, but EXPLAIN
65 FORMAT=tree shows computed tokens for both optimizers.
66 */
68
69#endif // SQL_JOIN_OPTIMIZER_EXPLAIN_ACCESS_PATH_H
Definition: sql_optimizer.h:133
This class represents a query expression (one query block or several query blocks combined with UNION...
Definition: sql_lex.h:627
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
std::string PrintQueryPlan(THD *ethd, const THD *query_thd, Query_expression *unit)
Print out an access path and all of its children (if any) in a tree.
Definition: explain_access_path.cc:2117
std::string GetForceSubplanToken(AccessPath *path, JOIN *join)
Generate a digest based on the subplan that the given access path represents.
Definition: explain_access_path.cc:2196
static char * path
Definition: mysqldump.cc:149
std::string join(const detail::range auto &rng, std::string_view delim)
join elements of a range into a string separated by a delimiter.
Definition: string.h:74
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:227