<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="show-profile">
      </a>
      15.7.7.32 SHOW PROFILE Statement
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045169824480">
  </a>
  <a class="indexterm" name="idm46045169823408">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa46723182"><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">SHOW</span> <span class="token keyword">PROFILE</span> <span class="token punctuation">[</span><span class="token keyword"><em class="replaceable">type</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">type</em></span><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">FOR</span> <span class="token keyword">QUERY</span> <em class="replaceable">n</em><span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">LIMIT</span> <span class="token keyword"><em class="replaceable">row_count</em></span> <span class="token punctuation">[</span><span class="token keyword">OFFSET</span> <span class="token keyword"><em class="replaceable">offset</em></span><span class="token punctuation">]</span><span class="token punctuation">]</span>

<span class="token keyword"><em class="replaceable">type</em></span>: {
    <span class="token keyword">ALL</span>
  <span class="token operator">|</span> <span class="token keyword">BLOCK</span> <span class="token keyword">IO</span>
  <span class="token operator">|</span> <span class="token keyword">CONTEXT</span> <span class="token keyword">SWITCHES</span>
  <span class="token operator">|</span> <span class="token keyword">CPU</span>
  <span class="token operator">|</span> <span class="token keyword">IPC</span>
  <span class="token operator">|</span> <span class="token keyword">MEMORY</span>
  <span class="token operator">|</span> <span class="token keyword">PAGE</span> <span class="token keyword">FAULTS</span>
  <span class="token operator">|</span> <span class="token keyword">SOURCE</span>
  <span class="token operator">|</span> <span class="token keyword">SWAPS</span>
}</code></pre>
  </div>
  <p>
   The
   <a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
    <code class="literal">
     SHOW PROFILE
    </code>
   </a>
   and
   <a class="link" href="show-profiles.html" title="15.7.7.33 SHOW PROFILES Statement">
    <code class="literal">
     SHOW PROFILES
    </code>
   </a>
   statements display
        profiling information that indicates resource usage for
        statements executed during the course of the current session.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    The
    <a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
     <code class="literal">
      SHOW PROFILE
     </code>
    </a>
    and
    <a class="link" href="show-profiles.html" title="15.7.7.33 SHOW PROFILES Statement">
     <code class="literal">
      SHOW PROFILES
     </code>
    </a>
    statements are
          deprecated; expect them to be removed in a future MySQL
          release. Use the
    <a class="link" href="performance-schema.html" title="Chapter 29 MySQL Performance Schema">
     Performance Schema
    </a>
    instead; see
    <a class="xref" href="performance-schema-query-profiling.html" title="29.19.1 Query Profiling Using Performance Schema">
     Section 29.19.1, “Query Profiling Using Performance Schema”
    </a>
    .
   </p>
  </div>
  <p>
   To control profiling, use the
   <a class="link" href="server-system-variables.html#sysvar_profiling">
    <code class="literal">
     profiling
    </code>
   </a>
   session variable,
        which has a default value of 0 (
   <code class="literal">
    OFF
   </code>
   ). Enable
        profiling by setting
   <a class="link" href="server-system-variables.html#sysvar_profiling">
    <code class="literal">
     profiling
    </code>
   </a>
   to 1 or
   <code class="literal">
    ON
   </code>
   :
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa93814122"><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> profiling <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   <a class="link" href="show-profiles.html" title="15.7.7.33 SHOW PROFILES Statement">
    <code class="literal">
     SHOW PROFILES
    </code>
   </a>
   displays a list of
        the most recent statements sent to the server. The size of the
        list is controlled by the
   <a class="link" href="server-system-variables.html#sysvar_profiling_history_size">
    <code class="literal">
     profiling_history_size
    </code>
   </a>
   session
        variable, which has a default value of 15. The maximum value is
        100. Setting the value to 0 has the practical effect of
        disabling profiling.
  </p>
  <p>
   All statements are profiled except
   <a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
    <code class="literal">
     SHOW
        PROFILE
    </code>
   </a>
   and
   <a class="link" href="show-profiles.html" title="15.7.7.33 SHOW PROFILES Statement">
    <code class="literal">
     SHOW
        PROFILES
    </code>
   </a>
   , so neither of those statements appears in
        the profile list. Malformed statements are profiled. For
        example,
   <code class="literal">
    SHOW PROFILING
   </code>
   is an illegal
        statement, and a syntax error occurs if you try to execute it,
        but it shows up in the profiling list.
  </p>
  <p>
   <a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
    <code class="literal">
     SHOW PROFILE
    </code>
   </a>
   displays detailed
        information about a single statement. Without the
   <code class="literal">
    FOR
        QUERY
    <em class="replaceable">
     <code>
      n
     </code>
    </em>
   </code>
   clause, the output
        pertains to the most recently executed statement. If
   <code class="literal">
    FOR QUERY
    <em class="replaceable">
     <code>
      n
     </code>
    </em>
   </code>
   is
        included,
   <a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
    <code class="literal">
     SHOW PROFILE
    </code>
   </a>
   displays
        information for statement
   <em class="replaceable">
    <code>
     n
    </code>
   </em>
   . The
        values of
   <em class="replaceable">
    <code>
     n
    </code>
   </em>
   correspond to the
   <code class="literal">
    Query_ID
   </code>
   values displayed by
   <a class="link" href="show-profiles.html" title="15.7.7.33 SHOW PROFILES Statement">
    <code class="literal">
     SHOW PROFILES
    </code>
   </a>
   .
  </p>
  <p>
   The
   <code class="literal">
    LIMIT
    <em class="replaceable">
     <code>
      row_count
     </code>
    </em>
   </code>
   clause may be
        given to limit the output to
   <em class="replaceable">
    <code>
     row_count
    </code>
   </em>
   rows. If
   <code class="literal">
    LIMIT
   </code>
   is given,
   <code class="literal">
    OFFSET
    <em class="replaceable">
     <code>
      offset
     </code>
    </em>
   </code>
   may be added to
        begin the output
   <em class="replaceable">
    <code>
     offset
    </code>
   </em>
   rows into the
        full set of rows.
  </p>
  <p>
   By default,
   <a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
    <code class="literal">
     SHOW PROFILE
    </code>
   </a>
   displays
   <code class="literal">
    Status
   </code>
   and
   <code class="literal">
    Duration
   </code>
   columns. The
   <code class="literal">
    Status
   </code>
   values are like the
   <code class="literal">
    State
   </code>
   values displayed by
   <a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
    <code class="literal">
     SHOW PROCESSLIST
    </code>
   </a>
   , although there
        might be some minor differences in interpretation for the two
        statements for some status values (see
   <a class="xref" href="thread-information.html" title="10.14 Examining Server Thread (Process) Information">
    Section 10.14, “Examining Server Thread (Process) Information”
   </a>
   ).
  </p>
  <p>
   Optional
   <em class="replaceable">
    <code>
     type
    </code>
   </em>
   values may be specified
        to display specific additional types of information:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       ALL
      </code>
      displays all information
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       BLOCK IO
      </code>
      displays counts for block input
            and output operations
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       CONTEXT SWITCHES
      </code>
      displays counts for
            voluntary and involuntary context switches
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       CPU
      </code>
      displays user and system CPU usage
            times
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       IPC
      </code>
      displays counts for messages sent and
            received
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       MEMORY
      </code>
      is not currently implemented
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       PAGE FAULTS
      </code>
      displays counts for major and
            minor page faults
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SOURCE
      </code>
      displays the names of functions
            from the source code, together with the name and line number
            of the file in which the function occurs
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SWAPS
      </code>
      displays swap counts
     </p>
    </li>
   </ul>
  </div>
  <p>
   Profiling is enabled per session. When a session ends, its
        profiling information is lost.
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa10812481"><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">@@profiling</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>
<span class="token output"><span class="token punctuation">|</span> @@profiling <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>
<span class="token output"><span class="token punctuation">|</span>           0 <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>
<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> profiling <span class="token operator">=</span> <span class="token number">1</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">DROP</span> <span class="token keyword">TABLE</span> <span class="token keyword">IF</span> <span class="token keyword">EXISTS</span> t1<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 1 warning (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> T1 <span class="token punctuation">(</span>id <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">PROFILES</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>
<span class="token output"><span class="token punctuation">|</span> Query_ID <span class="token punctuation">|</span> Duration <span class="token punctuation">|</span> Query                    <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>
<span class="token output"><span class="token punctuation">|</span>        0 <span class="token punctuation">|</span> 0.000088 <span class="token punctuation">|</span> SET PROFILING = 1        <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>        1 <span class="token punctuation">|</span> 0.000136 <span class="token punctuation">|</span> DROP TABLE IF EXISTS t1  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>        2 <span class="token punctuation">|</span> 0.011947 <span class="token punctuation">|</span> CREATE TABLE t1 (id INT) <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>
<span class="token output">3 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">PROFILE</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>
<span class="token output"><span class="token punctuation">|</span> Status               <span class="token punctuation">|</span> Duration <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>
<span class="token output"><span class="token punctuation">|</span> checking permissions <span class="token punctuation">|</span> 0.000040 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> creating table       <span class="token punctuation">|</span> 0.000056 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> After create         <span class="token punctuation">|</span> 0.011363 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> query end            <span class="token punctuation">|</span> 0.000375 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> freeing items        <span class="token punctuation">|</span> 0.000089 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> logging slow query   <span class="token punctuation">|</span> 0.000019 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> cleaning up          <span class="token punctuation">|</span> 0.000005 <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>
<span class="token output">7 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">PROFILE</span> <span class="token keyword">FOR</span> <span class="token keyword">QUERY</span> <span class="token number">1</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> Status             <span class="token punctuation">|</span> Duration <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> query end          <span class="token punctuation">|</span> 0.000107 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> freeing items      <span class="token punctuation">|</span> 0.000008 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> logging slow query <span class="token punctuation">|</span> 0.000015 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> cleaning up        <span class="token punctuation">|</span> 0.000006 <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">4 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">PROFILE</span> <span class="token keyword">CPU</span> <span class="token keyword">FOR</span> <span class="token keyword">QUERY</span> <span class="token number">2</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>
<span class="token output"><span class="token punctuation">|</span> Status               <span class="token punctuation">|</span> Duration <span class="token punctuation">|</span> CPU_user <span class="token punctuation">|</span> CPU_system <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>
<span class="token output"><span class="token punctuation">|</span> checking permissions <span class="token punctuation">|</span> 0.000040 <span class="token punctuation">|</span> 0.000038 <span class="token punctuation">|</span>   0.000002 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> creating table       <span class="token punctuation">|</span> 0.000056 <span class="token punctuation">|</span> 0.000028 <span class="token punctuation">|</span>   0.000028 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> After create         <span class="token punctuation">|</span> 0.011363 <span class="token punctuation">|</span> 0.000217 <span class="token punctuation">|</span>   0.001571 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> query end            <span class="token punctuation">|</span> 0.000375 <span class="token punctuation">|</span> 0.000013 <span class="token punctuation">|</span>   0.000028 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> freeing items        <span class="token punctuation">|</span> 0.000089 <span class="token punctuation">|</span> 0.000010 <span class="token punctuation">|</span>   0.000014 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> logging slow query   <span class="token punctuation">|</span> 0.000019 <span class="token punctuation">|</span> 0.000009 <span class="token punctuation">|</span>   0.000010 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> cleaning up          <span class="token punctuation">|</span> 0.000005 <span class="token punctuation">|</span> 0.000003 <span class="token punctuation">|</span>   0.000002 <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>
<span class="token output">7 rows in set (0.00 sec)</span></code></pre>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    Profiling is only partially functional on some architectures.
          For values that depend on the
    <code class="literal">
     getrusage()
    </code>
    system call,
    <code class="literal">
     NULL
    </code>
    is returned on systems
          such as Windows that do not support the call. In addition,
          profiling is per process and not per thread. This means that
          activity on threads within the server other than your own may
          affect the timing information that you see.
   </p>
  </div>
  <p>
   Profiling information is also available from the
   <code class="literal">
    INFORMATION_SCHEMA
   </code>
   <a class="link" href="information-schema-profiling-table.html" title="28.3.24 The INFORMATION_SCHEMA PROFILING Table">
    <code class="literal">
     PROFILING
    </code>
   </a>
   table. See
   <a class="xref" href="information-schema-profiling-table.html" title="28.3.24 The INFORMATION_SCHEMA PROFILING Table">
    Section 28.3.24, “The INFORMATION_SCHEMA PROFILING Table”
   </a>
   . For
        example, the following queries are equivalent:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa9688795"><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">SHOW</span> <span class="token keyword">PROFILE</span> <span class="token keyword">FOR</span> <span class="token keyword">QUERY</span> <span class="token number">2</span><span class="token punctuation">;</span>

<span class="token keyword">SELECT</span> STATE<span class="token punctuation">,</span> <span class="token function">FORMAT</span><span class="token punctuation">(</span>DURATION<span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> DURATION
<span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>PROFILING
<span class="token keyword">WHERE</span> QUERY_ID <span class="token operator">=</span> <span class="token number">2</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> SEQ<span class="token punctuation">;</span></code></pre>
  </div>
 </div>
 <br/>
</div>
