<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="performance-schema-stage-tables">
      </a>
      29.12.5 Performance Schema Stage Event Tables
     </h3>
    </div>
   </div>
  </div>
  <div class="toc">
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="performance-schema-events-stages-current-table.html">
       29.12.5.1 The events_stages_current Table
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-events-stages-history-table.html">
       29.12.5.2 The events_stages_history Table
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-events-stages-history-long-table.html">
       29.12.5.3 The events_stages_history_long Table
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <p>
   The Performance Schema instruments stages, which are steps
        during the statement-execution process, such as parsing a
        statement, opening a table, or performing a
   <code class="literal">
    filesort
   </code>
   operation. Stages correspond to the
        thread states displayed by
   <a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
    <code class="literal">
     SHOW
        PROCESSLIST
    </code>
   </a>
   or that are visible in the Information
        Schema
   <a class="link" href="information-schema-processlist-table.html" title="28.3.23 The INFORMATION_SCHEMA PROCESSLIST Table">
    <code class="literal">
     PROCESSLIST
    </code>
   </a>
   table. Stages
        begin and end when state values change.
  </p>
  <p>
   Within the event hierarchy, wait events nest within stage
        events, which nest within statement events, which nest within
        transaction events.
  </p>
  <p>
   These tables store stage events:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
       <code class="literal">
        events_stages_current
       </code>
      </a>
      : The
            current stage event for each thread.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-events-stages-history-table.html" title="29.12.5.2 The events_stages_history Table">
       <code class="literal">
        events_stages_history
       </code>
      </a>
      : The most
            recent stage events that have ended per thread.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-events-stages-history-long-table.html" title="29.12.5.3 The events_stages_history_long Table">
       <code class="literal">
        events_stages_history_long
       </code>
      </a>
      : The
            most recent stage events that have ended globally (across
            all threads).
     </p>
    </li>
   </ul>
  </div>
  <p>
   The following sections describe the stage event tables. There
        are also summary tables that aggregate information about stage
        events; see
   <a class="xref" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
    Section 29.12.20.2, “Stage Summary Tables”
   </a>
   .
  </p>
  <p>
   For more information about the relationship between the three
        stage event tables, see
   <a class="xref" href="performance-schema-event-tables.html" title="29.9 Performance Schema Tables for Current and Historical Events">
    Section 29.9, “Performance Schema Tables for Current and Historical Events”
   </a>
   .
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="performance-schema-stage-tables.html#stage-event-configuration" title="Configuring Stage Event Collection">
       Configuring Stage Event Collection
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="performance-schema-stage-tables.html#stage-event-progress" title="Stage Event Progress Information">
       Stage Event Progress Information
      </a>
     </p>
    </li>
   </ul>
  </div>
  <h4>
   <a name="stage-event-configuration">
   </a>
   Configuring Stage Event Collection
  </h4>
  <p>
   To control whether to collect stage events, set the state of the
        relevant instruments and consumers:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      The
      <a class="link" href="performance-schema-setup-instruments-table.html" title="29.12.2.3 The setup_instruments Table">
       <code class="literal">
        setup_instruments
       </code>
      </a>
      table
            contains instruments with names that begin with
      <code class="literal">
       stage
      </code>
      . Use these instruments to enable or
            disable collection of individual stage event classes.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
       <code class="literal">
        setup_consumers
       </code>
      </a>
      table
            contains consumer values with names corresponding to the
            current and historical stage event table names. Use these
            consumers to filter collection of stage events.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Other than those instruments that provide statement progress
        information, the stage instruments are disabled by default. For
        example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa44753526"><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 keyword">NAME</span><span class="token punctuation">,</span> ENABLED<span class="token punctuation">,</span> TIMED
       <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_instruments
       <span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">RLIKE</span> <span class="token string">'stage/sql/[a-c]'</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>
<span class="token output"><span class="token punctuation">|</span> NAME                                               <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span> TIMED <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>
<span class="token output"><span class="token punctuation">|</span> stage/sql/After create                             <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/allocating local table                   <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/altering table                           <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/committing alter table to storage engine <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Changing master                          <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Checking master version                  <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/checking permissions                     <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/cleaning up                              <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/closing tables                           <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Connecting to master                     <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/converting HEAP to MyISAM                <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Copying to group table                   <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Copying to tmp table                     <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/copy to tmp table                        <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Creating sort index                      <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/creating table                           <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Creating tmp table                       <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span> NO    <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></code></pre>
  </div>
  <p>
   Stage event instruments that provide statement progress
        information are enabled and timed by default:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa88807775"><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 keyword">NAME</span><span class="token punctuation">,</span> ENABLED<span class="token punctuation">,</span> TIMED
       <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_instruments
       <span class="token keyword">WHERE</span> ENABLED<span class="token operator">=</span><span class="token string">'YES'</span> <span class="token operator">AND</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">"stage/%"</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>
<span class="token output"><span class="token punctuation">|</span> NAME                                                 <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span> TIMED <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>
<span class="token output"><span class="token punctuation">|</span> stage/sql/copy to tmp table                          <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Applying batch of row changes (write)      <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Applying batch of row changes (update)     <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Applying batch of row changes (delete)     <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (end)                       <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (flush)                     <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (insert)                    <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (log apply index)           <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (log apply table)           <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (merge sort)                <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (read PK and internal sort) <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/buffer pool load                        <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/clone (file copy)                       <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/clone (redo copy)                       <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/clone (page copy)                       <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <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></code></pre>
  </div>
  <p>
   The stage consumers are disabled by default:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87869710"><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 operator">*</span>
       <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_consumers
       <span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_stages%'</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>
<span class="token output"><span class="token punctuation">|</span> NAME                       <span class="token punctuation">|</span> ENABLED <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>
<span class="token output"><span class="token punctuation">|</span> events_stages_current      <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history      <span class="token punctuation">|</span> NO      <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history_long <span class="token punctuation">|</span> NO      <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></code></pre>
  </div>
  <p>
   To control stage event collection at server startup, use lines
        like these in your
   <code class="filename">
    my.cnf
   </code>
   file:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Enable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa18643036"><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-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">performance-schema-instrument</span><span class="token attr-value"><span class="token punctuation">=</span>'stage/%=ON'</span>
<span class="token constant">performance-schema-consumer-events-stages-current</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span>
<span class="token constant">performance-schema-consumer-events-stages-history</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span>
<span class="token constant">performance-schema-consumer-events-stages-history-long</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Disable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa80493868"><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-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">performance-schema-instrument</span><span class="token attr-value"><span class="token punctuation">=</span>'stage/%=OFF'</span>
<span class="token constant">performance-schema-consumer-events-stages-current</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span>
<span class="token constant">performance-schema-consumer-events-stages-history</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span>
<span class="token constant">performance-schema-consumer-events-stages-history-long</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   To control stage event collection at runtime, update the
   <a class="link" href="performance-schema-setup-instruments-table.html" title="29.12.2.3 The setup_instruments Table">
    <code class="literal">
     setup_instruments
    </code>
   </a>
   and
   <a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
    <code class="literal">
     setup_consumers
    </code>
   </a>
   tables:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Enable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa33264932"><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">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'YES'</span><span class="token punctuation">,</span> TIMED <span class="token operator">=</span> <span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'stage/%'</span><span class="token punctuation">;</span>

<span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_stages%'</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Disable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa78760998"><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">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'NO'</span><span class="token punctuation">,</span> TIMED <span class="token operator">=</span> <span class="token string">'NO'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'stage/%'</span><span class="token punctuation">;</span>

<span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'NO'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_stages%'</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   To collect only specific stage events, enable only the
        corresponding stage instruments. To collect stage events only
        for specific stage event tables, enable the stage instruments
        but only the stage consumers corresponding to the desired
        tables.
  </p>
  <p>
   For additional information about configuring event collection,
        see
   <a class="xref" href="performance-schema-startup-configuration.html" title="29.3 Performance Schema Startup Configuration">
    Section 29.3, “Performance Schema Startup Configuration”
   </a>
   ,
        and
   <a class="xref" href="performance-schema-runtime-configuration.html" title="29.4 Performance Schema Runtime Configuration">
    Section 29.4, “Performance Schema Runtime Configuration”
   </a>
   .
  </p>
  <h4>
   <a name="stage-event-progress">
   </a>
   Stage Event Progress Information
  </h4>
  <p>
   The Performance Schema stage event tables contain two columns
        that, taken together, provide a stage progress indicator for
        each row:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       WORK_COMPLETED
      </code>
      : The number of work units
            completed for the stage
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       WORK_ESTIMATED
      </code>
      : The number of work units
            expected for the stage
     </p>
    </li>
   </ul>
  </div>
  <p>
   Each column is
   <code class="literal">
    NULL
   </code>
   if no progress
        information is provided for an instrument. Interpretation of the
        information, if it is available, depends entirely on the
        instrument implementation. The Performance Schema tables provide
        a container to store progress data, but make no assumptions
        about the semantics of the metric itself:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      A
      <span class="quote">
       “
       <span class="quote">
        work unit
       </span>
       ”
      </span>
      is an integer metric that
            increases over time during execution, such as the number of
            bytes, rows, files, or tables processed. The definition of
      <span class="quote">
       “
       <span class="quote">
        work unit
       </span>
       ”
      </span>
      for a particular instrument is left
            to the instrumentation code providing the data.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       WORK_COMPLETED
      </code>
      value can increase one
            or many units at a time, depending on the instrumented code.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       WORK_ESTIMATED
      </code>
      value can change
            during the stage, depending on the instrumented code.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Instrumentation for a stage event progress indicator can
        implement any of the following behaviors:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      No progress instrumentation
     </p>
     <p>
      This is the most typical case, where no progress data is
            provided. The
      <code class="literal">
       WORK_COMPLETED
      </code>
      and
      <code class="literal">
       WORK_ESTIMATED
      </code>
      columns are both
      <code class="literal">
       NULL
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Unbounded progress instrumentation
     </p>
     <p>
      Only the
      <code class="literal">
       WORK_COMPLETED
      </code>
      column is
            meaningful. No data is provided for the
      <code class="literal">
       WORK_ESTIMATED
      </code>
      column, which displays 0.
     </p>
     <p>
      By querying the
      <a class="link" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
       <code class="literal">
        events_stages_current
       </code>
      </a>
      table for
            the monitored session, a monitoring application can report
            how much work has been performed so far, but cannot report
            whether the stage is near completion. Currently, no stages
            are instrumented like this.
     </p>
    </li>
    <li class="listitem">
     <p>
      Bounded progress instrumentation
     </p>
     <p>
      The
      <code class="literal">
       WORK_COMPLETED
      </code>
      and
      <code class="literal">
       WORK_ESTIMATED
      </code>
      columns are both
            meaningful.
     </p>
     <p>
      This type of progress indicator is appropriate for an
            operation with a defined completion criterion, such as the
            table-copy instrument described later. By querying the
      <a class="link" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
       <code class="literal">
        events_stages_current
       </code>
      </a>
      table for
            the monitored session, a monitoring application can report
            how much work has been performed so far, and can report the
            overall completion percentage for the stage, by computing
            the
      <code class="literal">
       WORK_COMPLETED
      </code>
      /
      <code class="literal">
       WORK_ESTIMATED
      </code>
      ratio.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <code class="literal">
    stage/sql/copy to tmp table
   </code>
   instrument
        illustrates how progress indicators work. During execution of an
   <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
    <code class="literal">
     ALTER TABLE
    </code>
   </a>
   statement, the
   <code class="literal">
    stage/sql/copy to tmp table
   </code>
   stage is used,
        and this stage can execute potentially for a long time,
        depending on the size of the data to copy.
  </p>
  <p>
   The table-copy task has a defined termination (all rows copied),
        and the
   <code class="literal">
    stage/sql/copy to tmp table
   </code>
   stage is
        instrumented to provided bounded progress information: The work
        unit used is number of rows copied,
   <code class="literal">
    WORK_COMPLETED
   </code>
   and
   <code class="literal">
    WORK_ESTIMATED
   </code>
   are both meaningful, and their
        ratio indicates task percentage complete.
  </p>
  <p>
   To enable the instrument and the relevant consumers, execute
        these statements:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa16048643"><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">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED<span class="token operator">=</span><span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span><span class="token operator">=</span><span class="token string">'stage/sql/copy to tmp table'</span><span class="token punctuation">;</span>

<span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">SET</span> ENABLED<span class="token operator">=</span><span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_stages_%'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   To see the progress of an ongoing
   <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
    <code class="literal">
     ALTER
        TABLE
    </code>
   </a>
   statement, select from the
   <a class="link" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
    <code class="literal">
     events_stages_current
    </code>
   </a>
   table.
  </p>
 </div>
 <br/>
</div>
