Understanding MySQL EXPLAIN FORMAT=TREE and EXPLAIN ANALYZE
This article explains MySQL's experimental EXPLAIN FORMAT=TREE feature and the later EXPLAIN ANALYZE extension, showing how they present execution plans, estimated costs, actual runtime metrics, and how to interpret the tree output for query optimization.
MySQL 8.0.16 introduced the experimental feature EXPLAIN FORMAT=TREE which displays the execution plan as a tree with estimated cost and rows; MySQL 8.0.18 added EXPLAIN ANALYZE that actually runs the query and shows real execution time, rows, and loops.
Example commands and their output are shown, illustrating the tree structure and the additional actual metrics provided by EXPLAIN ANALYZE :
mysql> explain format=tree SELECT * FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2 WHERE id < 10);
mysql> explain analyze SELECT * FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2 WHERE id < 10)\G
The article explains how to read the tree from right‑to‑left until a parallel iterator is encountered, then from top‑to‑bottom for parallel iterators, and describes the execution order for a sample query using a nested‑loop inner join.
Key fields such as cost (estimated execution cost), rows (estimated vs. actual row count), actual time (time to fetch first row and total time), and loops (number of iterations) are clarified, with links to further documentation for deeper details.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.