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