<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="explain">
      </a>
      15.8.2 EXPLAIN Statement
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045168200480">
  </a>
  <a class="indexterm" name="idm46045168199408">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa17947713"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{<span class="token keyword">EXPLAIN</span> <span class="token operator">|</span> <span class="token keyword">DESCRIBE</span> <span class="token operator">|</span> <span class="token keyword">DESC</span>}
    <em class="replaceable">tbl_name</em> <span class="token punctuation">[</span><em class="replaceable">col_name</em> <span class="token operator">|</span> <em class="replaceable">wild</em><span class="token punctuation">]</span>

{<span class="token keyword">EXPLAIN</span> <span class="token operator">|</span> <span class="token keyword">DESCRIBE</span> <span class="token operator">|</span> <span class="token keyword">DESC</span>}
    <span class="token punctuation">[</span><em class="replaceable">explain_type</em><span class="token punctuation">]</span> <span class="token punctuation">[</span><span class="token keyword">INTO</span> <em class="replaceable">variable</em><span class="token punctuation">]</span>
    {<span class="token punctuation">[</span><em class="replaceable">schema_spec</em><span class="token punctuation">]</span> <em class="replaceable">explainable_stmt</em> <span class="token operator">|</span> <span class="token keyword">FOR</span> <span class="token keyword">CONNECTION</span> <em class="replaceable">connection_id</em>}

{<span class="token keyword">EXPLAIN</span> <span class="token operator">|</span> <span class="token keyword">DESCRIBE</span> <span class="token operator">|</span> <span class="token keyword">DESC</span>} <span class="token keyword">ANALYZE</span> <span class="token punctuation">[</span><span class="token keyword">FORMAT</span> <span class="token operator">=</span> <span class="token keyword">TREE</span><span class="token punctuation">]</span> <span class="token punctuation">[</span><em class="replaceable">schema_spec</em><span class="token punctuation">]</span> <em class="replaceable">select_statement</em>

<em class="replaceable">explain_type</em>: {
    <span class="token keyword">FORMAT</span> <span class="token operator">=</span> <em class="replaceable">format_name</em>
}

<em class="replaceable">format_name</em>: {
    <span class="token keyword">TRADITIONAL</span>
  <span class="token operator">|</span> <span class="token datatype">JSON</span>
  <span class="token operator">|</span> <span class="token keyword">TREE</span>
}

<em class="replaceable">explainable_stmt</em>: {
    <span class="token keyword">SELECT</span> statement
  <span class="token operator">|</span> <span class="token keyword">TABLE</span> statement
  <span class="token operator">|</span> <span class="token keyword">DELETE</span> statement
  <span class="token operator">|</span> <span class="token keyword">INSERT</span> statement
  <span class="token operator">|</span> <span class="token keyword">REPLACE</span> statement
  <span class="token operator">|</span> <span class="token keyword">UPDATE</span> statement
}

<em class="replaceable">schema_spec</em>:
<span class="token keyword">FOR</span> {<span class="token keyword">SCHEMA</span> <span class="token operator">|</span> <span class="token keyword">DATABASE</span>} <span class="token keyword"><em class="replaceable">schema_name</em></span></code></pre>
  </div>
  <p>
   The
   <a class="link" href="describe.html" title="15.8.1 DESCRIBE Statement">
    <code class="literal">
     DESCRIBE
    </code>
   </a>
   and
   <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
    <code class="literal">
     EXPLAIN
    </code>
   </a>
   statements are synonyms. In
      practice, the
   <a class="link" href="describe.html" title="15.8.1 DESCRIBE Statement">
    <code class="literal">
     DESCRIBE
    </code>
   </a>
   keyword is
      more often used to obtain information about table structure,
      whereas
   <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
    <code class="literal">
     EXPLAIN
    </code>
   </a>
   is used to obtain a
      query execution plan (that is, an explanation of how MySQL would
      execute a query).
  </p>
  <p>
   The following discussion uses the
   <a class="link" href="describe.html" title="15.8.1 DESCRIBE Statement">
    <code class="literal">
     DESCRIBE
    </code>
   </a>
   and
   <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
    <code class="literal">
     EXPLAIN
    </code>
   </a>
   keywords in accordance with
      those uses, but the MySQL parser treats them as completely
      synonymous.
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="explain.html#explain-table-structure" title="Obtaining Table Structure Information">
       Obtaining Table Structure Information
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="explain.html#explain-execution-plan" title="Obtaining Execution Plan Information">
       Obtaining Execution Plan Information
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="explain.html#explain-analyze" title="Obtaining Information with EXPLAIN ANALYZE">
       Obtaining Information with EXPLAIN ANALYZE
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="explain-table-structure">
       </a>
       Obtaining Table Structure Information
      </h4>
     </div>
    </div>
   </div>
   <p>
    <a class="link" href="describe.html" title="15.8.1 DESCRIBE Statement">
     <code class="literal">
      DESCRIBE
     </code>
    </a>
    provides information
        about the columns in a table:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa50605938"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">DESCRIBE</span> City<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Field      <span class="token punctuation">|</span> Type     <span class="token punctuation">|</span> Null <span class="token punctuation">|</span> Key <span class="token punctuation">|</span> Default <span class="token punctuation">|</span> Extra          <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Id         <span class="token punctuation">|</span> int(11)  <span class="token punctuation">|</span> NO   <span class="token punctuation">|</span> PRI <span class="token punctuation">|</span> NULL    <span class="token punctuation">|</span> auto_increment <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> Name       <span class="token punctuation">|</span> char(35) <span class="token punctuation">|</span> NO   <span class="token punctuation">|</span>     <span class="token punctuation">|</span>         <span class="token punctuation">|</span>                <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> Country    <span class="token punctuation">|</span> char(3)  <span class="token punctuation">|</span> NO   <span class="token punctuation">|</span> UNI <span class="token punctuation">|</span>         <span class="token punctuation">|</span>                <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> District   <span class="token punctuation">|</span> char(20) <span class="token punctuation">|</span> YES  <span class="token punctuation">|</span> MUL <span class="token punctuation">|</span>         <span class="token punctuation">|</span>                <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> Population <span class="token punctuation">|</span> int(11)  <span class="token punctuation">|</span> NO   <span class="token punctuation">|</span>     <span class="token punctuation">|</span> 0       <span class="token punctuation">|</span>                <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
   </div>
   <p>
    <a class="link" href="describe.html" title="15.8.1 DESCRIBE Statement">
     <code class="literal">
      DESCRIBE
     </code>
    </a>
    is a shortcut for
    <a class="link" href="show-columns.html" title="15.7.7.6 SHOW COLUMNS Statement">
     <code class="literal">
      SHOW COLUMNS
     </code>
    </a>
    . These statements
        also display information for views. The description for
    <a class="link" href="show-columns.html" title="15.7.7.6 SHOW COLUMNS Statement">
     <code class="literal">
      SHOW COLUMNS
     </code>
    </a>
    provides more
        information about the output columns. See
    <a class="xref" href="show-columns.html" title="15.7.7.6 SHOW COLUMNS Statement">
     Section 15.7.7.6, “SHOW COLUMNS Statement”
    </a>
    .
   </p>
   <p>
    By default,
    <a class="link" href="describe.html" title="15.8.1 DESCRIBE Statement">
     <code class="literal">
      DESCRIBE
     </code>
    </a>
    displays
        information about all columns in the table.
    <em class="replaceable">
     <code>
      col_name
     </code>
    </em>
    , if given, is the name of a
        column in the table. In this case, the statement displays
        information only for the named column.
    <em class="replaceable">
     <code>
      wild
     </code>
    </em>
    , if given, is a pattern string.
        It can contain the SQL
    <code class="literal">
     %
    </code>
    and
    <code class="literal">
     _
    </code>
    wildcard characters. In this case, the
        statement displays output only for the columns with names
        matching the string. There is no need to enclose the string
        within quotation marks unless it contains spaces or other
        special characters.
   </p>
   <a class="indexterm" name="idm46045168158464">
   </a>
   <a class="indexterm" name="idm46045168157392">
   </a>
   <p>
    The
    <a class="link" href="describe.html" title="15.8.1 DESCRIBE Statement">
     <code class="literal">
      DESCRIBE
     </code>
    </a>
    statement is
        provided for compatibility with Oracle.
   </p>
   <p>
    The
    <a class="link" href="show-create-table.html" title="15.7.7.11 SHOW CREATE TABLE Statement">
     <code class="literal">
      SHOW CREATE TABLE
     </code>
    </a>
    ,
    <a class="link" href="show-table-status.html" title="15.7.7.38 SHOW TABLE STATUS Statement">
     <code class="literal">
      SHOW TABLE STATUS
     </code>
    </a>
    , and
    <a class="link" href="show-index.html" title="15.7.7.23 SHOW INDEX Statement">
     <code class="literal">
      SHOW INDEX
     </code>
    </a>
    statements also
        provide information about tables. See
    <a class="xref" href="show.html" title="15.7.7 SHOW Statements">
     Section 15.7.7, “SHOW Statements”
    </a>
    .
   </p>
   <p>
    The
    <a class="link" href="server-system-variables.html#sysvar_explain_format">
     <code class="literal">
      explain_format
     </code>
    </a>
    system
        variable has no effect on the output of
    <code class="literal">
     EXPLAIN
    </code>
    when used to obtain information about
        table columns.
   </p>
   <p>
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="explain-execution-plan">
       </a>
       Obtaining Execution Plan Information
      </h4>
     </div>
    </div>
   </div>
   <p>
    The
    <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
     <code class="literal">
      EXPLAIN
     </code>
    </a>
    statement provides
        information about how MySQL executes statements:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
        <code class="literal">
         EXPLAIN
        </code>
       </a>
       works with
       <a class="link" href="select.html" title="15.2.13 SELECT Statement">
        <code class="literal">
         SELECT
        </code>
       </a>
       ,
       <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
        <code class="literal">
         DELETE
        </code>
       </a>
       ,
       <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
        <code class="literal">
         INSERT
        </code>
       </a>
       ,
       <a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
        <code class="literal">
         REPLACE
        </code>
       </a>
       ,
       <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
        <code class="literal">
         UPDATE
        </code>
       </a>
       , and
       <a class="link" href="table.html" title="15.2.16 TABLE Statement">
        <code class="literal">
         TABLE
        </code>
       </a>
       statements.
      </p>
     </li>
     <li class="listitem">
      <p>
       When
       <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
        <code class="literal">
         EXPLAIN
        </code>
       </a>
       is used with an
            explainable statement, MySQL displays information from the
            optimizer about the statement execution plan. That is, MySQL
            explains how it would process the statement, including
            information about how tables are joined and in which order.
            For information about using
       <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
        <code class="literal">
         EXPLAIN
        </code>
       </a>
       to obtain execution
            plan information, see
       <a class="xref" href="explain-output.html" title="10.8.2 EXPLAIN Output Format">
        Section 10.8.2, “EXPLAIN Output Format”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       When
       <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
        <code class="literal">
         EXPLAIN
        </code>
       </a>
       is used with
       <code class="literal">
        FOR CONNECTION
        <em class="replaceable">
         <code>
          connection_id
         </code>
        </em>
       </code>
       rather
            than an explainable statement, it displays the execution
            plan for the statement executing in the named connection.
            See
       <a class="xref" href="explain-for-connection.html" title="10.8.4 Obtaining Execution Plan Information for a Named Connection">
        Section 10.8.4, “Obtaining Execution Plan Information for a Named Connection”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       For explainable statements,
       <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
        <code class="literal">
         EXPLAIN
        </code>
       </a>
       produces additional
            execution plan information that can be displayed using
       <a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
        <code class="literal">
         SHOW WARNINGS
        </code>
       </a>
       . See
       <a class="xref" href="explain-extended.html" title="10.8.3 Extended EXPLAIN Output Format">
        Section 10.8.3, “Extended EXPLAIN Output Format”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
        <code class="literal">
         EXPLAIN
        </code>
       </a>
       is useful for
            examining queries involving partitioned tables. See
       <a class="xref" href="partitioning-info.html" title="26.3.5 Obtaining Information About Partitions">
        Section 26.3.5, “Obtaining Information About Partitions”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       The
       <code class="literal">
        FORMAT
       </code>
       option can be used to select
            the output format.
       <code class="literal">
        TRADITIONAL
       </code>
       presents
            the output in tabular format. This is the default if no
       <code class="literal">
        FORMAT
       </code>
       option is present.
       <code class="literal">
        JSON
       </code>
       format displays the information in
            JSON format.
       <code class="literal">
        TREE
       </code>
       provides tree-like
            output with more precise descriptions of query handling than
            the
       <code class="literal">
        TRADITIONAL
       </code>
       format; it is the only
            format which shows hash join usage (see
       <a class="xref" href="hash-joins.html" title="10.2.1.4 Hash Join Optimization">
        Section 10.2.1.4, “Hash Join Optimization”
       </a>
       ) and is always used for
       <code class="literal">
        EXPLAIN ANALYZE
       </code>
       .
      </p>
      <p>
       In MySQL 8.4, the default output format used by
       <code class="literal">
        EXPLAIN
       </code>
       (that is, when it has no
       <code class="literal">
        FORMAT
       </code>
       option) is determined by the value
            of the
       <a class="link" href="server-system-variables.html#sysvar_explain_format">
        <code class="literal">
         explain_format
        </code>
       </a>
       system variable. The precise effects of this variable are
            described later in this section.
      </p>
      <p>
       MySQL 8.4 supports an additional
       <code class="literal">
        INTO
       </code>
       option with
       <code class="literal">
        EXPLAIN
            FORMAT=JSON
       </code>
       , which enables saving the JSON
            formatted output into a user variable, like this:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa18363959"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token datatype">JSON</span> <span class="token keyword">INTO</span> <span class="token variable">@myselect</span> 
<span class="token prompt">    -&gt;</span>     <span class="token keyword">SELECT</span> <span class="token keyword">name</span> <span class="token keyword">FROM</span> a <span class="token keyword">WHERE</span> id <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token variable">@myselect</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
@myex<span class="token punctuation">:</span> {
  "query_block"<span class="token punctuation">:</span> {
    "select_id"<span class="token punctuation">:</span> 1,
    "cost_info"<span class="token punctuation">:</span> {
      "query_cost"<span class="token punctuation">:</span> "1.00"
    },
    "table"<span class="token punctuation">:</span> {
      "table_name"<span class="token punctuation">:</span> "a",
      "access_type"<span class="token punctuation">:</span> "const",
      "possible_keys"<span class="token punctuation">:</span> [
        "PRIMARY"
      ],
      "key"<span class="token punctuation">:</span> "PRIMARY",
      "used_key_parts"<span class="token punctuation">:</span> [
        "id"
      ],
      "key_length"<span class="token punctuation">:</span> "4",
      "ref"<span class="token punctuation">:</span> [
        "const"
      ],
      "rows_examined_per_scan"<span class="token punctuation">:</span> 1,
      "rows_produced_per_join"<span class="token punctuation">:</span> 1,
      "filtered"<span class="token punctuation">:</span> "100.00",
      "cost_info"<span class="token punctuation">:</span> {
        "read_cost"<span class="token punctuation">:</span> "0.00",
        "eval_cost"<span class="token punctuation">:</span> "0.10",
        "prefix_cost"<span class="token punctuation">:</span> "0.00",
        "data_read_per_join"<span class="token punctuation">:</span> "408"
      },
      "used_columns"<span class="token punctuation">:</span> [
        "id",
        "name"
      ]
    }
  }
}
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
      </div>
      <p>
       This works with any explainable statement
            (
       <a class="link" href="select.html" title="15.2.13 SELECT Statement">
        <code class="literal">
         SELECT
        </code>
       </a>
       ,
       <a class="link" href="table.html" title="15.2.16 TABLE Statement">
        <code class="literal">
         TABLE
        </code>
       </a>
       ,
       <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
        <code class="literal">
         INSERT
        </code>
       </a>
       ,
       <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
        <code class="literal">
         UPDATE
        </code>
       </a>
       ,
       <a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
        <code class="literal">
         REPLACE
        </code>
       </a>
       , or
       <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
        <code class="literal">
         DELETE
        </code>
       </a>
       ). Examples using
       <code class="literal">
        UPDATE
       </code>
       and
       <code class="literal">
        DELETE
       </code>
       statements are shown here:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa55811252"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token datatype">JSON</span> <span class="token keyword">INTO</span> <span class="token variable">@myupdate</span> 
<span class="token prompt">    -&gt;</span>   <span class="token keyword">UPDATE</span> a <span class="token keyword">SET</span> name2 <span class="token operator">=</span> <span class="token string">"garcia"</span> <span class="token keyword">WHERE</span> id <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">;</span>              
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token datatype">JSON</span> <span class="token keyword">INTO</span> <span class="token variable">@mydelete</span> 
<span class="token prompt">    -&gt;</span>     <span class="token keyword">DELETE</span> <span class="token keyword">FROM</span> a <span class="token keyword">WHERE</span> name1 <span class="token operator">LIKE</span> <span class="token string">'%e%'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token variable">@myupdate</span><span class="token punctuation">,</span> <span class="token variable">@mydelete</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
@myupdate<span class="token punctuation">:</span> {
  "query_block"<span class="token punctuation">:</span> {
    "select_id"<span class="token punctuation">:</span> 1,
    "table"<span class="token punctuation">:</span> {
      "update"<span class="token punctuation">:</span> true,
      "table_name"<span class="token punctuation">:</span> "a",
      "access_type"<span class="token punctuation">:</span> "range",
      "possible_keys"<span class="token punctuation">:</span> [
        "PRIMARY"
      ],
      "key"<span class="token punctuation">:</span> "PRIMARY",
      "used_key_parts"<span class="token punctuation">:</span> [
        "id"
      ],
      "key_length"<span class="token punctuation">:</span> "4",
      "ref"<span class="token punctuation">:</span> [
        "const"
      ],
      "rows_examined_per_scan"<span class="token punctuation">:</span> 1,
      "filtered"<span class="token punctuation">:</span> "100.00",
      "attached_condition"<span class="token punctuation">:</span> "(`db`.`a`.`id` = 3)"
    }
  }
}
@mydelete<span class="token punctuation">:</span> {
  "query_block"<span class="token punctuation">:</span> {
    "select_id"<span class="token punctuation">:</span> 1,
    "table"<span class="token punctuation">:</span> {
      "delete"<span class="token punctuation">:</span> true,
      "table_name"<span class="token punctuation">:</span> "a",
      "access_type"<span class="token punctuation">:</span> "ALL",
      "rows_examined_per_scan"<span class="token punctuation">:</span> 2,
      "filtered"<span class="token punctuation">:</span> "100.00",
      "attached_condition"<span class="token punctuation">:</span> "(`db`.`a`.`name1` like '%e%')"
    }
  }
}
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
      </div>
      <p>
       You can work with this value using MySQL JSON functions as
            you would with any other JSON value, as in these examples
            using
       <a class="link" href="json-search-functions.html#function_json-extract">
        <code class="literal">
         JSON_EXTRACT()
        </code>
       </a>
       :
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa27194678"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">JSON_EXTRACT</span><span class="token punctuation">(</span><span class="token variable">@myselect</span><span class="token punctuation">,</span> <span class="token string">"$.query_block.table.key"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> JSON_EXTRACT(@myselect, "$.query_block.table.key") <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> "PRIMARY"                                          <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.01 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">JSON_EXTRACT</span><span class="token punctuation">(</span><span class="token variable">@myupdate</span><span class="token punctuation">,</span> <span class="token string">"$.query_block.table.access_type"</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> U_acc<span class="token punctuation">,</span>
<span class="token prompt">    -&gt;</span>        <span class="token function">JSON_EXTRACT</span><span class="token punctuation">(</span><span class="token variable">@mydelete</span><span class="token punctuation">,</span> <span class="token string">"$.query_block.table.access_type"</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> D_acc<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> U_acc   <span class="token punctuation">|</span> D_acc <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> "range" <span class="token punctuation">|</span> "ALL" <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
      </div>
      <p>
       For complex statements, the JSON output can be quite large;
            in particular, it can be difficult when reading it to pair
            the closing bracket and opening brackets; to cause the JSON
            structure's key, if it has one, to be repeated near the
            closing bracket, set
       <a class="link" href="server-system-variables.html#sysvar_end_markers_in_json">
        <code class="literal">
         end_markers_in_json=ON
        </code>
       </a>
       . You
            should be aware that while this makes the output easier to
            read, it also renders the JSON invalid, causing JSON
            functions to raise an error.
      </p>
      <p>
       See also
       <a class="xref" href="json-functions.html" title="14.17 JSON Functions">
        Section 14.17, “JSON Functions”
       </a>
       .
      </p>
      <p>
       Trying to use an
       <code class="literal">
        INTO
       </code>
       clause without
            explicitly including
       <code class="literal">
        FORMAT=JSON
       </code>
       causes
       <code class="literal">
        EXPLAIN
       </code>
       to be rejected with
       <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_explain_into_implicit_format_not_supported" target="_top">
        <code class="literal">
         ER_EXPLAIN_INTO_IMPLICIT_FORMAT_NOT_SUPPORTED
        </code>
       </a>
       .
            This is true regardless of the current value of the
       <a class="link" href="server-system-variables.html#sysvar_explain_format">
        <code class="literal">
         explain_format
        </code>
       </a>
       system
            variable.
      </p>
      <p>
       The
       <code class="literal">
        INTO
       </code>
       clause is not supported with
       <code class="literal">
        FOR CONNECTION
       </code>
       .
      </p>
      <p>
       <code class="literal">
        INTO
       </code>
       is also not supported with
       <code class="literal">
        EXPLAIN ANALYZE
       </code>
       when
       <a class="link" href="server-system-variables.html#sysvar_explain_json_format_version">
        <code class="literal">
         explain_json_format_version=1
        </code>
       </a>
       .
      </p>
      <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
       <div class="admon-title">
        Important
       </div>
       <p>
        If, for any reason, the statement to be analyzed is
              rejected, the user variable is not updated.
       </p>
      </div>
     </li>
     <li class="listitem">
      <p>
       MySQL 8.4 supports a
       <code class="literal">
        FOR
            SCHEMA
       </code>
       clause, which causes
       <code class="literal">
        EXPLAIN
       </code>
       to behave as if the statement to
            be analyzed had been executed in the named database;
       <code class="literal">
        FOR DATABASE
       </code>
       is supported as a synonym. A
            simple example of use is shown here:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa32954117"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">USE</span> b<span class="token punctuation">;</span>
<span class="token keyword">Database</span> <span class="token keyword">changed</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">SCHEMA</span> s1<span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.01 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">SCHEMA</span> s2<span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.01 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">USE</span> s1<span class="token punctuation">;</span>
<span class="token keyword">Database</span> <span class="token keyword">changed</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t <span class="token punctuation">(</span>c1 <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span> c2 <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.04 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">USE</span> s2<span class="token punctuation">;</span>
<span class="token keyword">Database</span> <span class="token keyword">changed</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t <span class="token punctuation">(</span>c1 <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span> c2 <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span> <span class="token keyword">KEY</span> i1 <span class="token punctuation">(</span>c2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.04 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">USE</span> b<span class="token punctuation">;</span>
<span class="token keyword">Database</span> <span class="token keyword">changed</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span> <span class="token keyword">FOR</span> <span class="token keyword">SCHEMA</span> s1 <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> c2 <span class="token operator">&gt;</span> <span class="token number">50</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -&gt; Filter<span class="token punctuation">:</span> (t.c2 &gt; 50)  (cost=0.35 rows=1)</span>
<span class="token prompt">    -&gt;</span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t  <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>

<span class="token output">1 row in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span> <span class="token keyword">FOR</span> <span class="token keyword">SCHEMA</span> s2 <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> c2 <span class="token operator">&gt;</span> <span class="token number">50</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -&gt; Filter<span class="token punctuation">:</span> (t.c2 &gt; 50)  (cost=0.35 rows=1)</span>
<span class="token prompt">    -&gt;</span> Covering <span class="token keyword">index</span> scan <span class="token keyword">on</span> t <span class="token keyword">using</span> i1  <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>

<span class="token output">1 row in set (0.00 sec)</span></code></pre>
      </div>
      <p>
       If the database does not exist, the statement is rejected
            with
       <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_bad_db_error" target="_top">
        <code class="literal">
         ER_BAD_DB_ERROR
        </code>
       </a>
       . If the
            user does not have the necessary privileges to run the
            statement, it is rejected with
       <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_dbaccess_denied_error" target="_top">
        <code class="literal">
         ER_DBACCESS_DENIED_ERROR
        </code>
       </a>
       .
      </p>
      <p>
       <code class="literal">
        FOR SCHEMA
       </code>
       is not compatible with
       <code class="literal">
        FOR CONNECTION
       </code>
       .
      </p>
     </li>
    </ul>
   </div>
   <p>
    <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
     <code class="literal">
      EXPLAIN
     </code>
    </a>
    requires the same
        privileges required to execute the explained statement.
        Additionally,
    <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
     <code class="literal">
      EXPLAIN
     </code>
    </a>
    also
        requires the
    <a class="link" href="privileges-provided.html#priv_show-view">
     <code class="literal">
      SHOW VIEW
     </code>
    </a>
    privilege
        for any explained view.
    <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
     <code class="literal">
      EXPLAIN ... FOR
        CONNECTION
     </code>
    </a>
    also requires the
    <a class="link" href="privileges-provided.html#priv_process">
     <code class="literal">
      PROCESS
     </code>
    </a>
    privilege if the
        specified connection belongs to a different user.
   </p>
   <p>
    The
    <a class="link" href="server-system-variables.html#sysvar_explain_format">
     <code class="literal">
      explain_format
     </code>
    </a>
    system
        variable determines the format of the output from
    <code class="literal">
     EXPLAIN
    </code>
    when used to display a query
        execution plan. This variable can take any of the values used
        with the
    <code class="literal">
     FORMAT
    </code>
    option, with the addition of
    <code class="literal">
     DEFAULT
    </code>
    as a synonym for
    <code class="literal">
     TRADITIONAL
    </code>
    . The following example uses the
    <code class="literal">
     country
    </code>
    table from the
    <code class="literal">
     world
    </code>
    database which can be obtained from
    <a class="ulink" href="/doc/index-other.html" target="_top">
     MySQL: Other
        Downloads
    </a>
    :
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa11144878"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">USE</span> world<span class="token punctuation">;</span> <span class="token comment" spellcheck="true"># Make world the current database</span>
<span class="token keyword">Database</span> <span class="token keyword">changed</span></code></pre>
   </div>
   <p>
    Checking the value of
    <code class="literal">
     explain_format
    </code>
    , we see
        that it has the default value, and that
    <code class="literal">
     EXPLAIN
    </code>
    (with no
    <code class="literal">
     FORMAT
    </code>
    option) therefore uses the traditional tabular output:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa13899415"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token variable">@@explain_format</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @@explain_format <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> TRADITIONAL      <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">SELECT</span> <span class="token keyword">Name</span> <span class="token keyword">FROM</span> country <span class="token keyword">WHERE</span> <span class="token keyword">Code</span> <span class="token operator">Like</span> <span class="token string">'A%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> id <span class="token punctuation">|</span> select_type <span class="token punctuation">|</span> table   <span class="token punctuation">|</span> partitions <span class="token punctuation">|</span> type  <span class="token punctuation">|</span> possible_keys <span class="token punctuation">|</span> key     <span class="token punctuation">|</span> key_len <span class="token punctuation">|</span> ref  <span class="token punctuation">|</span> rows <span class="token punctuation">|</span> filtered <span class="token punctuation">|</span> Extra       <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>  1 <span class="token punctuation">|</span> SIMPLE      <span class="token punctuation">|</span> country <span class="token punctuation">|</span> NULL       <span class="token punctuation">|</span> range <span class="token punctuation">|</span> PRIMARY       <span class="token punctuation">|</span> PRIMARY <span class="token punctuation">|</span> 12      <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span>   17 <span class="token punctuation">|</span>   100.00 <span class="token punctuation">|</span> Using where <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set, 1 warning (0.00 sec)</span></code></pre>
   </div>
   <p>
    If we set the value of
    <code class="literal">
     explain_format
    </code>
    to
    <code class="literal">
     TREE
    </code>
    , then rerun the same
    <code class="literal">
     EXPLAIN
    </code>
    statement, the output uses the
        tree-like format:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa1588670"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@@explain_format</span><span class="token operator">=</span><span class="token keyword">TREE</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token variable">@@explain_format</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @@explain_format <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> TREE             <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">SELECT</span> <span class="token keyword">Name</span> <span class="token keyword">FROM</span> country <span class="token keyword">WHERE</span> <span class="token keyword">Code</span> <span class="token operator">LIKE</span> <span class="token string">'A%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> EXPLAIN                                                                                                      <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token operator">|</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token keyword">Filter</span>: <span class="token punctuation">(</span>country<span class="token punctuation">.</span><span class="token punctuation">`</span><span class="token keyword">Code</span><span class="token punctuation">`</span> <span class="token operator">like</span> <span class="token string">'A%'</span><span class="token punctuation">)</span>  <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">3.67</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">17</span><span class="token punctuation">)</span>
<span class="token prompt">    -&gt;</span> <span class="token keyword">Index</span> <span class="token keyword">range</span> scan <span class="token keyword">on</span> country <span class="token keyword">using</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">over</span> <span class="token punctuation">(</span><span class="token string">'A'</span> <span class="token operator">&lt;=</span> <span class="token keyword">Code</span> <span class="token operator">&lt;=</span> <span class="token string">'A????????'</span><span class="token punctuation">)</span>  <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">3.67</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">17</span><span class="token punctuation">)</span>  <span class="token operator">|</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set, 1 warning (0.00 sec)</span></code></pre>
   </div>
   <p>
    As stated previously, the
    <code class="literal">
     FORMAT
    </code>
    option
        overrides this setting. Executing the same
    <code class="literal">
     EXPLAIN
    </code>
    statement using
    <code class="literal">
     FORMAT=JSON
    </code>
    instead of
    <code class="literal">
     FORMAT=TREE
    </code>
    shows that this is the case:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa81963003"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token datatype">JSON</span> <span class="token keyword">SELECT</span> <span class="token keyword">Name</span> <span class="token keyword">FROM</span> country <span class="token keyword">WHERE</span> <span class="token keyword">Code</span> <span class="token operator">LIKE</span> <span class="token string">'A%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> EXPLAIN                                                                      <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token operator">|</span> {
  <span class="token string">"query_block"</span>: {
    <span class="token string">"select_id"</span>: <span class="token number">1</span><span class="token punctuation">,</span>
    <span class="token string">"cost_info"</span>: {
      <span class="token string">"query_cost"</span>: <span class="token string">"3.67"</span>
    }<span class="token punctuation">,</span>
    <span class="token string">"table"</span>: {
      <span class="token string">"table_name"</span>: <span class="token string">"country"</span><span class="token punctuation">,</span>
      <span class="token string">"access_type"</span>: <span class="token string">"range"</span><span class="token punctuation">,</span>
      <span class="token string">"possible_keys"</span>: <span class="token punctuation">[</span>
        <span class="token string">"PRIMARY"</span>
      <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string">"key"</span>: <span class="token string">"PRIMARY"</span><span class="token punctuation">,</span>
      <span class="token string">"used_key_parts"</span>: <span class="token punctuation">[</span>
        <span class="token string">"Code"</span>
      <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string">"key_length"</span>: <span class="token string">"12"</span><span class="token punctuation">,</span>
      <span class="token string">"rows_examined_per_scan"</span>: <span class="token number">17</span><span class="token punctuation">,</span>
      <span class="token string">"rows_produced_per_join"</span>: <span class="token number">17</span><span class="token punctuation">,</span>
      <span class="token string">"filtered"</span>: <span class="token string">"100.00"</span><span class="token punctuation">,</span>
      <span class="token string">"cost_info"</span>: {
        <span class="token string">"read_cost"</span>: <span class="token string">"1.97"</span><span class="token punctuation">,</span>
        <span class="token string">"eval_cost"</span>: <span class="token string">"1.70"</span><span class="token punctuation">,</span>
        <span class="token string">"prefix_cost"</span>: <span class="token string">"3.67"</span><span class="token punctuation">,</span>
        <span class="token string">"data_read_per_join"</span>: <span class="token string">"16K"</span>
      }<span class="token punctuation">,</span>
      <span class="token string">"used_columns"</span>: <span class="token punctuation">[</span>
        <span class="token string">"Code"</span><span class="token punctuation">,</span>
        <span class="token string">"Name"</span>
      <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string">"attached_condition"</span>: <span class="token string">"(`world`.`country`.`Code` like 'A%')"</span>
    }
  }
}                                                                              <span class="token operator">|</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set, 1 warning (0.00 sec)</span></code></pre>
   </div>
   <p>
    To return the default output of
    <code class="literal">
     EXPLAIN
    </code>
    to
        the tabular format, set
    <code class="literal">
     explain_format
    </code>
    to
    <code class="literal">
     TRADITIONAL
    </code>
    . Alternatively, you can set it to
    <code class="literal">
     DEFAULT
    </code>
    , which has the same effect, as shown
        here:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa5299114"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@@explain_format</span><span class="token operator">=</span><span class="token keyword">DEFAULT</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token variable">@@explain_format</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @@explain_format <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> TRADITIONAL      <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
   </div>
   <a class="indexterm" name="idm46045168008576">
   </a>
   <a class="indexterm" name="idm46045168007072">
   </a>
   <p>
    MySQL 8.4 supports two versions of the JSON output
        format. Version 1 is the linear format always used in MySQL 8.2
        and earlier; this remains the default in MySQL 8.4,
        and is used in the examples already shown in this section.
        Version 2 of the JSON output format is based on access paths,
        and is intended to provide compatibility with future versions of
        the MySQL Optimizer. You can switch to the Version 2 format by
        setting the value of the
    <a class="link" href="server-system-variables.html#sysvar_explain_json_format_version">
     <code class="literal">
      explain_json_format_version
     </code>
    </a>
    server system variable to
    <code class="literal">
     2
    </code>
    , as shown here
        for the same
    <code class="literal">
     EXPLAIN
    </code>
    statement used in the
        previous example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa19629347"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token variable">@@explain_json_format_version</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @@explain_json_format_version <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                             1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@@explain_json_format_version</span> <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token variable">@@explain_json_format_version</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @@explain_json_format_version <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                             2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token datatype">JSON</span> <span class="token keyword">SELECT</span> <span class="token keyword">Name</span> <span class="token keyword">FROM</span> country <span class="token keyword">WHERE</span> <span class="token keyword">Code</span> <span class="token operator">LIKE</span> <span class="token string">'A%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> EXPLAIN                                                                      <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token operator">|</span> {
  <span class="token string">"query"</span>: <span class="token string">"/* select#1 */ select `world`.`country`.`Name` AS `Name` from `world`.`country` where (`world`.`country`.`Code` like 'A%')"</span><span class="token punctuation">,</span>
  <span class="token string">"inputs"</span>: <span class="token punctuation">[</span>
<span class="token inlinejson">    <span class="token punctuation">{</span>
      <span class="token property">"ranges"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token string">"('A' &lt;= Code &lt;= 'A????????')"</span>
      <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token property">"covering"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
      <span class="token property">"operation"</span><span class="token operator">:</span> <span class="token string">"Index range scan on country using PRIMARY over ('A' &lt;= Code &lt; 'A????????')"</span><span class="token punctuation">,</span>
      <span class="token property">"index_name"</span><span class="token operator">:</span> <span class="token string">"PRIMARY"</span><span class="token punctuation">,</span>
      <span class="token property">"table_name"</span><span class="token operator">:</span> <span class="token string">"country"</span><span class="token punctuation">,</span>
      <span class="token property">"access_type"</span><span class="token operator">:</span> <span class="token string">"index"</span><span class="token punctuation">,</span>
      <span class="token property">"estimated_rows"</span><span class="token operator">:</span> <span class="token number">17.0</span><span class="token punctuation">,</span>
      <span class="token property">"index_access_type"</span><span class="token operator">:</span> <span class="token string">"index_range_scan"</span><span class="token punctuation">,</span>
      <span class="token property">"estimated_total_cost"</span><span class="token operator">:</span> <span class="token number">3.668778400708174</span>
    <span class="token punctuation">}</span></span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">"condition"</span>: <span class="token string">"(country.`Code` like 'A%')"</span><span class="token punctuation">,</span>
  <span class="token string">"operation"</span>: <span class="token string">"Filter: (country.`Code` like 'A%')"</span><span class="token punctuation">,</span>
  <span class="token string">"access_type"</span>: <span class="token string">"filter"</span><span class="token punctuation">,</span>
  <span class="token string">"estimated_rows"</span>: <span class="token number">17.0</span><span class="token punctuation">,</span>
  <span class="token string">"estimated_total_cost"</span>: <span class="token number">3.668778400708174</span>
}                                                                              <span class="token operator">|</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
   </div>
   <p>
    After using the Version 2 format, you can cause the JSON output
        from all subsequent
    <code class="literal">
     EXPLAIN FORMAT=JSON
    </code>
    statements to revert to the Version 1 format by setting
    <code class="literal">
     explain_json_format_version
    </code>
    back to
    <code class="literal">
     1
    </code>
    (the default).
   </p>
   <p>
    The value of
    <code class="literal">
     explain_json_format_version
    </code>
    determines the version of the JSON output format employed by all
    <code class="literal">
     EXPLAIN
    </code>
    statements which use it, whether the
        JSON format is used because a given
    <code class="literal">
     EXPLAIN
    </code>
    statement includes an explicit
    <code class="literal">
     FORMAT=JSON
    </code>
    option, or because the JSON format is used automatically due to
        the
    <a class="link" href="server-system-variables.html#sysvar_explain_format">
     <code class="literal">
      explain_format
     </code>
    </a>
    system
        variable being set to
    <code class="literal">
     JSON
    </code>
    .
   </p>
   <a class="indexterm" name="idm46045167985984">
   </a>
   <p>
    With the help of
    <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
     <code class="literal">
      EXPLAIN
     </code>
    </a>
    , you can
        see where you should add indexes to tables so that the statement
        executes faster by using indexes to find rows. You can also use
    <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
     <code class="literal">
      EXPLAIN
     </code>
    </a>
    to check whether the
        optimizer joins the tables in an optimal order. To give a hint
        to the optimizer to use a join order corresponding to the order
        in which the tables are named in a
    <a class="link" href="select.html" title="15.2.13 SELECT Statement">
     <code class="literal">
      SELECT
     </code>
    </a>
    statement, begin the
        statement with
    <code class="literal">
     SELECT STRAIGHT_JOIN
    </code>
    rather
        than just
    <a class="link" href="select.html" title="15.2.13 SELECT Statement">
     <code class="literal">
      SELECT
     </code>
    </a>
    . (See
    <a class="xref" href="select.html" title="15.2.13 SELECT Statement">
     Section 15.2.13, “SELECT Statement”
    </a>
    .)
   </p>
   <p>
    The optimizer trace may sometimes provide information
        complementary to that of
    <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
     <code class="literal">
      EXPLAIN
     </code>
    </a>
    .
        However, the optimizer trace format and content are subject to
        change between versions. For details, see
    <a class="xref" href="optimizer-tracing.html" title="10.15 Tracing the Optimizer">
     Section 10.15, “Tracing the Optimizer”
    </a>
    .
   </p>
   <p>
    If you have a problem with indexes not being used when you
        believe that they should be, run
    <a class="link" href="analyze-table.html" title="15.7.3.1 ANALYZE TABLE Statement">
     <code class="literal">
      ANALYZE
        TABLE
     </code>
    </a>
    to update table statistics, such as cardinality
        of keys, that can affect the choices the optimizer makes. See
    <a class="xref" href="analyze-table.html" title="15.7.3.1 ANALYZE TABLE Statement">
     Section 15.7.3.1, “ANALYZE TABLE Statement”
    </a>
    .
   </p>
   <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Note
    </div>
    <p>
     MySQL Workbench has a Visual Explain capability that provides a
          visual representation of
     <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
      <code class="literal">
       EXPLAIN
      </code>
     </a>
     output. See
     <a class="ulink" href="/doc/workbench/en/wb-tutorial-visual-explain-dbt3.html" target="_top">
      Tutorial: Using Explain to Improve Query Performance
     </a>
     .
    </p>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="explain-analyze">
       </a>
       Obtaining Information with EXPLAIN ANALYZE
      </h4>
     </div>
    </div>
   </div>
   <p>
    <code class="literal">
     EXPLAIN ANALYZE
    </code>
    runs a statement and produces
    <a class="link" href="explain.html#explain-execution-plan" title="Obtaining Execution Plan Information">
     <code class="literal">
      EXPLAIN
     </code>
    </a>
    output along with timing and additional, iterator-based,
        information about how the optimizer's expectations matched
        the actual execution. For each iterator, the following
        information is provided:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Estimated execution cost
      </p>
      <p>
       (Some iterators are not accounted for by the cost model, and
            so are not included in the estimate.)
      </p>
     </li>
     <li class="listitem">
      <p>
       Estimated number of returned rows
      </p>
     </li>
     <li class="listitem">
      <p>
       Time to return first row
      </p>
     </li>
     <li class="listitem">
      <p>
       Time spent executing this iterator (including child
            iterators, but not parent iterators), in milliseconds.
      </p>
      <p>
       (When there are multiple loops, this figure shows the
            average time per loop.)
      </p>
     </li>
     <li class="listitem">
      <p>
       Number of rows returned by the iterator
      </p>
     </li>
     <li class="listitem">
      <p>
       Number of loops
      </p>
     </li>
    </ul>
   </div>
   <p>
    The query execution information is displayed using the
    <code class="literal">
     TREE
    </code>
    output format, in which nodes represent
        iterators.
    <code class="literal">
     EXPLAIN ANALYZE
    </code>
    always uses the
    <code class="literal">
     TREE
    </code>
    output format. This can optionally be
        specified explicitly using
    <code class="literal">
     FORMAT=TREE
    </code>
    ;
        formats other than
    <code class="literal">
     TREE
    </code>
    remain unsupported.
   </p>
   <p>
    <code class="literal">
     EXPLAIN ANALYZE
    </code>
    can be used with
    <a class="link" href="select.html" title="15.2.13 SELECT Statement">
     <code class="literal">
      SELECT
     </code>
    </a>
    statements, multi-table
    <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
     <code class="literal">
      UPDATE
     </code>
    </a>
    and
    <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
     <code class="literal">
      DELETE
     </code>
    </a>
    statements, and
    <a class="link" href="table.html" title="15.2.16 TABLE Statement">
     <code class="literal">
      TABLE
     </code>
    </a>
    statements.
   </p>
   <p>
    You can terminate this statement using
    <a class="link" href="kill.html" title="15.7.8.4 KILL Statement">
     <code class="literal">
      KILL QUERY
     </code>
    </a>
    or
    <span class="keycap">
     <strong>
      CTRL-C
     </strong>
    </span>
    .
   </p>
   <p>
    <code class="literal">
     EXPLAIN ANALYZE
    </code>
    cannot be used with
    <code class="literal">
     FOR CONNECTION
    </code>
    .
   </p>
   <p>
    Example output:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa77680242"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">ANALYZE</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">JOIN</span> t2 <span class="token keyword">ON</span> <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>c1 <span class="token operator">=</span> t2<span class="token punctuation">.</span>c2<span class="token punctuation">)</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -&gt; Inner hash join (t2.c2 = t1.c1)  (cost=3.5 rows=5) 
(actual time=0.121..0.131 rows=1 loops=1) </span>
<span class="token prompt">    -&gt;</span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t2  <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.07</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">5</span><span class="token punctuation">)</span> 
<span class="token punctuation">(</span>actual <span class="token datatype">time</span><span class="token operator">=</span><span class="token number">0.0126</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token number">0.0221</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">5</span> loops<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span> 
<span class="token prompt">    -&gt;</span> <span class="token keyword">Hash</span>
<span class="token prompt">        -&gt;</span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t1  <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.75</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">5</span><span class="token punctuation">)</span> 
<span class="token punctuation">(</span>actual <span class="token datatype">time</span><span class="token operator">=</span><span class="token number">0.0372</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token number">0.0534</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">5</span> loops<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">ANALYZE</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t3 <span class="token keyword">WHERE</span> i <span class="token operator">&gt;</span> <span class="token number">8</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -&gt; Filter<span class="token punctuation">:</span> (t3.i &gt; 8)  (cost=0.75 rows=1.67) 
(actual time=0.0168..0.0182 rows=1 loops=1)</span>
<span class="token prompt">    -&gt;</span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t3  <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.75</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">5</span><span class="token punctuation">)</span> 
<span class="token punctuation">(</span>actual <span class="token datatype">time</span><span class="token operator">=</span><span class="token number">0.015</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token number">0.0167</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">5</span> loops<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">ANALYZE</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t3 <span class="token keyword">WHERE</span> pk <span class="token operator">&gt;</span> <span class="token number">17</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -&gt; Filter<span class="token punctuation">:</span> (t3.pk &gt; 17)  (cost=0.91 rows=2) 
(actual time=0.0334..0.042 rows=2 loops=1)</span>
<span class="token prompt">    -&gt;</span> <span class="token keyword">Index</span> <span class="token keyword">range</span> scan <span class="token keyword">on</span> t3 <span class="token keyword">using</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">over</span> <span class="token punctuation">(</span><span class="token number">17</span> <span class="token operator">&lt;</span> pk<span class="token punctuation">)</span>  
<span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.91</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token punctuation">(</span>actual <span class="token datatype">time</span><span class="token operator">=</span><span class="token number">0.0306</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token number">0.0384</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">2</span> loops<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span></code></pre>
   </div>
   <p>
    The tables used in the example output were created by the
        statements shown here:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa31774541"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1 <span class="token punctuation">(</span>
    c1 <span class="token datatype">INTEGER</span> <span class="token keyword">DEFAULT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
    c2 <span class="token datatype">INTEGER</span> <span class="token keyword">DEFAULT</span> <span class="token boolean">NULL</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t2 <span class="token punctuation">(</span>
    c1 <span class="token datatype">INTEGER</span> <span class="token keyword">DEFAULT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
    c2 <span class="token datatype">INTEGER</span> <span class="token keyword">DEFAULT</span> <span class="token boolean">NULL</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t3 <span class="token punctuation">(</span>
    pk <span class="token datatype">INTEGER</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
    i <span class="token datatype">INTEGER</span> <span class="token keyword">DEFAULT</span> <span class="token boolean">NULL</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
   </div>
   <p>
    Values shown for
    <code class="literal">
     actual time
    </code>
    in the output of
        this statement are expressed in milliseconds.
   </p>
   <p>
    <a class="link" href="server-system-variables.html#sysvar_explain_format">
     <code class="literal">
      explain_format
     </code>
    </a>
    has the
        following effects on
    <code class="literal">
     EXPLAIN ANALYZE
    </code>
    :
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       If the value of this variable is
       <code class="literal">
        TRADITIONAL
       </code>
       or
       <code class="literal">
        TREE
       </code>
       (or the synonym
       <code class="literal">
        DEFAULT
       </code>
       ),
       <code class="literal">
        EXPLAIN ANALYZE
       </code>
       uses the
       <code class="literal">
        TREE
       </code>
       format. This ensures that this
            statement continues to use the
       <code class="literal">
        TREE
       </code>
       format by default, as it did prior to the introduction of
       <code class="literal">
        explain_format
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       If the value of
       <code class="literal">
        explain_format
       </code>
       is
       <code class="literal">
        JSON
       </code>
       ,
       <code class="literal">
        EXPLAIN ANALYZE
       </code>
       returns an error unless
       <code class="literal">
        FORMAT=TREE
       </code>
       is
            specified as part of the statement. This is due to the fact
            that
       <code class="literal">
        EXPLAIN ANALYZE
       </code>
       supports only the
       <code class="literal">
        TREE
       </code>
       output format.
      </p>
     </li>
    </ul>
   </div>
   <p>
    We illustrate the behavior described in the second point here,
        re-using the last
    <code class="literal">
     EXPLAIN ANALYZE
    </code>
    statement
        from the previous example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa67455450"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@@explain_format</span><span class="token operator">=</span><span class="token datatype">JSON</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token variable">@@explain_format</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @@explain_format <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> JSON             <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">ANALYZE</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t3 <span class="token keyword">WHERE</span> pk <span class="token operator">&gt;</span> <span class="token number">17</span>\G
<span class="token output">ERROR 1235 (42000)<span class="token punctuation">:</span> This version of MySQL doesn't yet support 'EXPLAIN ANALYZE with JSON format'
</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">ANALYZE</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TRADITIONAL</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t3 <span class="token keyword">WHERE</span> pk <span class="token operator">&gt;</span> <span class="token number">17</span>\G
<span class="token output">ERROR 1235 (42000)<span class="token punctuation">:</span> This version of MySQL doesn't yet support 'EXPLAIN ANALYZE with TRADITIONAL format'
</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">ANALYZE</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t3 <span class="token keyword">WHERE</span> pk <span class="token operator">&gt;</span> <span class="token number">17</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -&gt; Filter<span class="token punctuation">:</span> (t3.pk &gt; 17)  (cost=1.26 rows=5)
(actual time=0.013..0.016 rows=5 loops=1)</span>
<span class="token prompt">    -&gt;</span> <span class="token keyword">Index</span> <span class="token keyword">range</span> scan <span class="token keyword">on</span> t3 <span class="token keyword">using</span> <span class="token keyword">PRIMARY</span>  <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">1.26</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">5</span><span class="token punctuation">)</span>
<span class="token punctuation">(</span>actual <span class="token datatype">time</span><span class="token operator">=</span><span class="token number">0.012</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token number">0.014</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">5</span> loops<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span></code></pre>
   </div>
   <p>
    Using
    <code class="literal">
     FORMAT=TRADITIONAL
    </code>
    or
    <code class="literal">
     FORMAT=JSON
    </code>
    with
    <code class="literal">
     EXPLAIN
        ANALYZE
    </code>
    always raises an error, regardless of the
        value of
    <code class="literal">
     explain_format
    </code>
    .
   </p>
   <p>
    In MySQL 8.4, numbers in the output of
    <code class="literal">
     EXPLAIN ANALYZE
    </code>
    and
    <code class="literal">
     EXPLAIN
        FORMAT=TREE
    </code>
    are formatted according to the following
        rules:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Numbers in the range 0.001-999999.5 are printed as decimal
            numbers.
      </p>
      <p>
       Decimal numbers less than 1000 have three significant
            digits; the remainder have four, five, or six.
      </p>
     </li>
     <li class="listitem">
      <p>
       Numbers outside the range 0.001-999999.5 are printed in
            engineering format. Examples of such values are
       <code class="literal">
        1.23e+9
       </code>
       and
       <code class="literal">
        934e-6
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       No trailing zeros are printed. For example, we print
       <code class="literal">
        2.3
       </code>
       rather than
       <code class="literal">
        2.30
       </code>
       ,
            and
       <code class="literal">
        1.2e+6
       </code>
       rather than
       <code class="literal">
        1.20e+6
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       Numbers less than
       <code class="literal">
        1e-12
       </code>
       are printed as
       <code class="literal">
        0
       </code>
       .
      </p>
     </li>
    </ul>
   </div>
  </div>
 </div>
 <br/>
</div>
