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