<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="performance-schema-stage-summary-tables">
      </a>
      29.12.20.2 Stage Summary Tables
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045069047408">
  </a>
  <a class="indexterm" name="idm46045069045888">
  </a>
  <a class="indexterm" name="idm46045069044368">
  </a>
  <a class="indexterm" name="idm46045069042848">
  </a>
  <a class="indexterm" name="idm46045069041328">
  </a>
  <a class="indexterm" name="idm46045069039808">
  </a>
  <a class="indexterm" name="idm46045069038288">
  </a>
  <a class="indexterm" name="idm46045069036768">
  </a>
  <a class="indexterm" name="idm46045069035248">
  </a>
  <a class="indexterm" name="idm46045069033728">
  </a>
  <p>
   The Performance Schema maintains tables for collecting current
          and recent stage events, and aggregates that information in
          summary tables.
   <a class="xref" href="performance-schema-stage-tables.html" title="29.12.5 Performance Schema Stage Event Tables">
    Section 29.12.5, “Performance Schema Stage Event Tables”
   </a>
   describes
          the events on which stage summaries are based. See that
          discussion for information about the content of stage events,
          the current and historical stage event tables, and how to
          control stage event collection, which is disabled by default.
  </p>
  <p>
   Example stage event summary information:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa83357700"><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>events_stages_summary_global_by_event_name\G
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 5. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
    EVENT_NAME<span class="token punctuation">:</span> stage/sql/checking permissions
    COUNT_STAR<span class="token punctuation">:</span> 57
SUM_TIMER_WAIT<span class="token punctuation">:</span> 26501888880
MIN_TIMER_WAIT<span class="token punctuation">:</span> 7317456
AVG_TIMER_WAIT<span class="token punctuation">:</span> 464945295
MAX_TIMER_WAIT<span class="token punctuation">:</span> 12858936792
...
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 9. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
    EVENT_NAME<span class="token punctuation">:</span> stage/sql/closing tables
    COUNT_STAR<span class="token punctuation">:</span> 37
SUM_TIMER_WAIT<span class="token punctuation">:</span> 662606568
MIN_TIMER_WAIT<span class="token punctuation">:</span> 1593864
AVG_TIMER_WAIT<span class="token punctuation">:</span> 17907891
MAX_TIMER_WAIT<span class="token punctuation">:</span> 437977248
...</span></code></pre>
  </div>
  <p>
   Each stage summary table has one or more grouping columns to
          indicate how the table aggregates events. Event names refer to
          names of event instruments in 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:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
       <code class="literal">
        events_stages_summary_by_account_by_event_name
       </code>
      </a>
      has
      <code class="literal">
       EVENT_NAME
      </code>
      ,
      <code class="literal">
       USER
      </code>
      , and
      <code class="literal">
       HOST
      </code>
      columns. Each row summarizes events for a given account
              (user and host combination) and event name.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
       <code class="literal">
        events_stages_summary_by_host_by_event_name
       </code>
      </a>
      has
      <code class="literal">
       EVENT_NAME
      </code>
      and
      <code class="literal">
       HOST
      </code>
      columns. Each row summarizes
              events for a given host and event name.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
       <code class="literal">
        events_stages_summary_by_thread_by_event_name
       </code>
      </a>
      has
      <code class="literal">
       THREAD_ID
      </code>
      and
      <code class="literal">
       EVENT_NAME
      </code>
      columns. Each row summarizes
              events for a given thread and event name.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
       <code class="literal">
        events_stages_summary_by_user_by_event_name
       </code>
      </a>
      has
      <code class="literal">
       EVENT_NAME
      </code>
      and
      <code class="literal">
       USER
      </code>
      columns. Each row summarizes
              events for a given user and event name.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
       <code class="literal">
        events_stages_summary_global_by_event_name
       </code>
      </a>
      has an
      <code class="literal">
       EVENT_NAME
      </code>
      column. Each row
              summarizes events for a given event name.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Each stage summary table has these summary columns containing
          aggregated values:
   <code class="literal">
    COUNT_STAR
   </code>
   ,
   <code class="literal">
    SUM_TIMER_WAIT
   </code>
   ,
   <code class="literal">
    MIN_TIMER_WAIT
   </code>
   ,
   <code class="literal">
    AVG_TIMER_WAIT
   </code>
   , and
   <code class="literal">
    MAX_TIMER_WAIT
   </code>
   . These columns are analogous
          to the columns of the same names in the wait event summary
          tables (see
   <a class="xref" href="performance-schema-wait-summary-tables.html" title="29.12.20.1 Wait Event Summary Tables">
    Section 29.12.20.1, “Wait Event Summary Tables”
   </a>
   ),
          except that the stage summary tables aggregate events from
   <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>
   rather than
   <a class="link" href="performance-schema-events-waits-current-table.html" title="29.12.4.1 The events_waits_current Table">
    <code class="literal">
     events_waits_current
    </code>
   </a>
   .
  </p>
  <p>
   The stage summary tables have these indexes:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
       <code class="literal">
        events_stages_summary_by_account_by_event_name
       </code>
      </a>
      :
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         Primary key on (
         <code class="literal">
          USER
         </code>
         ,
         <code class="literal">
          HOST
         </code>
         ,
         <code class="literal">
          EVENT_NAME
         </code>
         )
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
       <code class="literal">
        events_stages_summary_by_host_by_event_name
       </code>
      </a>
      :
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         Primary key on (
         <code class="literal">
          HOST
         </code>
         ,
         <code class="literal">
          EVENT_NAME
         </code>
         )
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
       <code class="literal">
        events_stages_summary_by_thread_by_event_name
       </code>
      </a>
      :
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         Primary key on (
         <code class="literal">
          THREAD_ID
         </code>
         ,
         <code class="literal">
          EVENT_NAME
         </code>
         )
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
       <code class="literal">
        events_stages_summary_by_user_by_event_name
       </code>
      </a>
      :
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         Primary key on (
         <code class="literal">
          USER
         </code>
         ,
         <code class="literal">
          EVENT_NAME
         </code>
         )
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
       <code class="literal">
        events_stages_summary_global_by_event_name
       </code>
      </a>
      :
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         Primary key on (
         <code class="literal">
          EVENT_NAME
         </code>
         )
        </p>
       </li>
      </ul>
     </div>
    </li>
   </ul>
  </div>
  <p>
   <a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
    <code class="literal">
     TRUNCATE TABLE
    </code>
   </a>
   is permitted for
          stage summary tables. It has these effects:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      For summary tables not aggregated by account, host, or
              user, truncation resets the summary columns to zero rather
              than removing rows.
     </p>
    </li>
    <li class="listitem">
     <p>
      For summary tables aggregated by account, host, or user,
              truncation removes rows for accounts, hosts, or users with
              no connections, and resets the summary columns to zero for
              the remaining rows.
     </p>
    </li>
   </ul>
  </div>
  <p>
   In addition, each stage summary table that is aggregated by
          account, host, user, or thread is implicitly truncated by
          truncation of the connection table on which it depends, or
          truncation of
   <a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
    <code class="literal">
     events_stages_summary_global_by_event_name
    </code>
   </a>
   .
          For details, see
   <a class="xref" href="performance-schema-connection-tables.html" title="29.12.8 Performance Schema Connection Tables">
    Section 29.12.8, “Performance Schema Connection Tables”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
