MySQL 9.3.0
Source Code Documentation
explain_access_path.h File Reference
#include <string>

Go to the source code of this file.

Functions

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. More...
 
std::string PrintQueryPlan (int level, AccessPath *path, JOIN *join, bool is_root_of_join)
 For debugging purposes. More...
 
std::string GetForceSubplanToken (AccessPath *path, JOIN *join)
 Generate a digest based on the subplan that the given access path represents. More...
 

Function Documentation

◆ GetForceSubplanToken()

std::string GetForceSubplanToken ( AccessPath path,
JOIN join 
)

Generate a digest based on the subplan that the given access path represents.

This can be used by developers to force a given subplan, to investigate e.g. whether a given choice is actually faster in practice, force-apply a plan from the old join optimizer (or at least the types of subplans that are ever considered; e.g. aggregation through temporary tables are not) into the hypergraph join optimizer (to see how it's costed), or whether a given plan is even generated. If DEBUG contains force_subplan_0x<token>, subplans with the given token are unconditionally preferred over all others.

The token returned is “0x<digest>”, where <digest> is the first 64 bits of the SHA-256 sum of this string:

desc1,desc2,...,[child1_desc:]0xchild1,[child2_desc:]0xchild2,<more children>

where desc1, desc2, etc. are the description lines given by EXPLAIN, and 0xchild1 is the token for children. The normal way to generate such tokens is to use SET DEBUG='+d,subplan_tokens' and look at the EXPLAIN FORMAT=tree, but in a pinch, you can also write them by hand and use sha256sum or a similar tool.

Only the hypergraph join optimizer honors token preferences, but EXPLAIN FORMAT=tree shows computed tokens for both optimizers.

◆ PrintQueryPlan() [1/2]

std::string PrintQueryPlan ( int  level,
AccessPath path,
JOIN join,
bool  is_root_of_join 
)

For debugging purposes.

◆ PrintQueryPlan() [2/2]

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.

To help identify the "shape" of the JSON output we add a version number on the format "Major.minor" that should be bumped according to these rules: Major: bumped when we make breaking changes between releases. This includes removal or renaming of fields or access paths and changes in field types, e.g. changing a string value to an array. Should be avoided. minor: bumped when we make additions to the format between releases, e.g. add new fields for some access paths, add new access paths. Should be bumped at most once per release. Reset minor to 0 when Major is bumped. This version number is not related to the explain_json_format_version system variable, and is only referring to the sub-versioning of the JSONv2 EXPLAIN format.