原文地址:https://dev.mysql.com/doc/refman/5.7/en/explain-output.html
Thestatement provides information about the execution plan for astatement.
returns a row of information for each table used in thestatement. It lists the tables in the output in the order that MySQL would read them while processing the statement. MySQL resolves all joins using a nested-loop join method. This means that MySQL reads a row from the first table,and then finds a matching row in the second table,the third table,and so on. When all tables are processed,MySQL outputs the selected columns and backtracks through the table list until a table is found for which there are more matching rows. The next row is read from this table and the process continues with the next table.
Before MySQL 5.7.3,when thekeyword is used,produces extra information that can be viewed by issuing astatement following thestatement.also displays the
column. See. As of MySQL 5.7.3,extended output is enabled by default and the
keyword is unnecessary.
You cannot use theand
keywords together in the samestatement. In addition,neither of these keywords can be used together with the
option. (
causes
to display extended and partition information automatically; using
has no effect on
output.)
Output Columns
EXPLAIN Output Columns
This section describes the output columns produced by. Later sections provide additional information about theandcolumns.
Each output row fromprovides information about one table. Each row contains the values summarized in,and described in more detail following the table. Column names are shown in the table's first column; the second column provides the equivalent property name shown in the output whenis used.
Table9.1EXPLAIN Output Columns
<div class="admon-title">Note
JSON properties which areare not displayed in JSON-formatted
output.
(JSON name:
)
Theidentifier. This is the sequential number of thewithin the query. The value can beif the row refers to the union result of other rows. In this case,the
to indicate that the row refers to the union of the rows withcolumn shows a value like
>M
,Nvalues ofM
andN.
(JSON name: none)
The type of,which can be any of those shown in the following table. A JSON-formattedexposes thetype as a property of a,unless it isor. The JSON names (where applicable) are also shown in the table.
Value
</tr>
<tr>
<td scope="row"><code class="literal">PRIMARY</td>
<td>None</td>
<td>Outermost<a class="link" title="14.2.9SELECT Syntax" href="https://dev.mysql.com/doc/refman/5.7/en/select.html"><code class="literal">SELECT
</td>
</tr>
<tr>
<td scope="row"><a class="link" title="14.2.9.3UNION Syntax" href="https://dev.mysql.com/doc/refman/5.7/en/union.html"><code class="literal">UNION</td>
<td>None</td>
<td>Second or later<a class="link" title="14.2.9SELECT Syntax" href="https://dev.mysql.com/doc/refman/5.7/en/select.html"><code class="literal">SELECTstatement in a<a class="link" title="14.2.9.3UNION Syntax" href="https://dev.mysql.com/doc/refman/5.7/en/union.html"><code class="literal">UNION
</td>
</tr>
<tr>
<td scope="row"><code class="literal">DEPENDENT UNION</td>
<td>
<code class="literal">dependent(<code class="literal">true)</td>
<td>Second or later<a class="link" title="14.2.9SELECT Syntax" href="https://dev.mysql.com/doc/refman/5.7/en/select.html"><code class="literal">SELECTstatement in a<a class="link" title="14.2.9.3UNION Syntax" href="https://dev.mysql.com/doc/refman/5.7/en/union.html"><code class="literal">UNION,dependent on outer query</td>
</tr>
<tr>
<td scope="row"><code class="literal">UNION RESULT</td>
<td><code class="literal">union_result</td>
<td>Result of a<a class="link" title="14.2.9.3UNION Syntax" href="https://dev.mysql.com/doc/refman/5.7/en/union.html"><code class="literal">UNION.</td>