<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="performance-schema-statement-summary-tables">
      </a>
      29.12.20.3 Statement Summary Tables
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045068967088">
  </a>
  <a class="indexterm" name="idm46045068965552">
  </a>
  <a class="indexterm" name="idm46045068964016">
  </a>
  <a class="indexterm" name="idm46045068962560">
  </a>
  <a class="indexterm" name="idm46045068961040">
  </a>
  <a class="indexterm" name="idm46045068959520">
  </a>
  <a class="indexterm" name="idm46045068958000">
  </a>
  <a class="indexterm" name="idm46045068956480">
  </a>
  <a class="indexterm" name="idm46045068954960">
  </a>
  <a class="indexterm" name="idm46045068953440">
  </a>
  <a class="indexterm" name="idm46045068951920">
  </a>
  <a class="indexterm" name="idm46045068950400">
  </a>
  <a class="indexterm" name="idm46045068948880">
  </a>
  <a class="indexterm" name="idm46045068947360">
  </a>
  <a class="indexterm" name="idm46045068945840">
  </a>
  <a class="indexterm" name="idm46045068944336">
  </a>
  <p>
   The Performance Schema maintains tables for collecting current
          and recent statement events, and aggregates that information
          in summary tables.
   <a class="xref" href="performance-schema-statement-tables.html" title="29.12.6 Performance Schema Statement Event Tables">
    Section 29.12.6, “Performance Schema Statement Event Tables”
   </a>
   describes the events on which statement summaries are based.
          See that discussion for information about the content of
          statement events, the current and historical statement event
          tables, and how to control statement event collection, which
          is partially disabled by default.
  </p>
  <p>
   Example statement event summary information:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa525453"><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_statements_summary_global_by_event_name\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
                 EVENT_NAME<span class="token punctuation">:</span> statement/sql/select
                 COUNT_STAR<span class="token punctuation">:</span> 54
             SUM_TIMER_WAIT<span class="token punctuation">:</span> 38860400000
             MIN_TIMER_WAIT<span class="token punctuation">:</span> 52400000
             AVG_TIMER_WAIT<span class="token punctuation">:</span> 719600000
             MAX_TIMER_WAIT<span class="token punctuation">:</span> 12631800000
              SUM_LOCK_TIME<span class="token punctuation">:</span> 88000000
                 SUM_ERRORS<span class="token punctuation">:</span> 0
               SUM_WARNINGS<span class="token punctuation">:</span> 0
          SUM_ROWS_AFFECTED<span class="token punctuation">:</span> 0
              SUM_ROWS_SENT<span class="token punctuation">:</span> 60
          SUM_ROWS_EXAMINED<span class="token punctuation">:</span> 120
SUM_CREATED_TMP_DISK_TABLES<span class="token punctuation">:</span> 0
     SUM_CREATED_TMP_TABLES<span class="token punctuation">:</span> 21
       SUM_SELECT_FULL_JOIN<span class="token punctuation">:</span> 16
 SUM_SELECT_FULL_RANGE_JOIN<span class="token punctuation">:</span> 0
           SUM_SELECT_RANGE<span class="token punctuation">:</span> 0
     SUM_SELECT_RANGE_CHECK<span class="token punctuation">:</span> 0
            SUM_SELECT_SCAN<span class="token punctuation">:</span> 41
      SUM_SORT_MERGE_PASSES<span class="token punctuation">:</span> 0
             SUM_SORT_RANGE<span class="token punctuation">:</span> 0
              SUM_SORT_ROWS<span class="token punctuation">:</span> 0
              SUM_SORT_SCAN<span class="token punctuation">:</span> 0
          SUM_NO_INDEX_USED<span class="token punctuation">:</span> 22
     SUM_NO_GOOD_INDEX_USED<span class="token punctuation">:</span> 0
               SUM_CPU_TIME<span class="token punctuation">:</span> 0
      MAX_CONTROLLED_MEMORY<span class="token punctuation">:</span> 2028360
           MAX_TOTAL_MEMORY<span class="token punctuation">:</span> 2853429
            COUNT_SECONDARY<span class="token punctuation">:</span> 0
...</span></code></pre>
  </div>
  <p>
   Each statement 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-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_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-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_summary_by_digest
       </code>
      </a>
      has
      <code class="literal">
       SCHEMA_NAME
      </code>
      and
      <code class="literal">
       DIGEST
      </code>
      columns. Each row summarizes
              events per schema and digest value. (The
      <code class="literal">
       DIGEST_TEXT
      </code>
      column contains the
              corresponding normalized statement digest text, but is
              neither a grouping nor a summary column. The
      <code class="literal">
       QUERY_SAMPLE_TEXT
      </code>
      ,
      <code class="literal">
       QUERY_SAMPLE_SEEN
      </code>
      , and
      <code class="literal">
       QUERY_SAMPLE_TIMER_WAIT
      </code>
      columns also
              are neither grouping nor summary columns; they support
              statement sampling.)
     </p>
     <p>
      The maximum number of rows in the table is autosized at
              server startup. To set this maximum explicitly, set the
      <a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_digests_size">
       <code class="literal">
        performance_schema_digests_size
       </code>
      </a>
      system variable at server startup.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_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-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_summary_by_program
       </code>
      </a>
      has
      <code class="literal">
       OBJECT_TYPE
      </code>
      ,
      <code class="literal">
       OBJECT_SCHEMA
      </code>
      , and
      <code class="literal">
       OBJECT_NAME
      </code>
      columns. Each row
              summarizes events for a given stored program (stored
              procedure or function, trigger, or event).
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_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-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_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-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_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>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-prepared-statements-instances-table.html" title="29.12.6.4 The prepared_statements_instances Table">
       <code class="literal">
        prepared_statements_instances
       </code>
      </a>
      has an
      <code class="literal">
       OBJECT_INSTANCE_BEGIN
      </code>
      column.
              Each row summarizes events for a given prepared statement.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Each statement summary table has these summary columns
          containing aggregated values (with exceptions as noted):
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <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>
      ,
      <code class="literal">
       MAX_TIMER_WAIT
      </code>
     </p>
     <p>
      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 statement summary tables aggregate events
              from
      <a class="link" href="performance-schema-events-statements-current-table.html" title="29.12.6.1 The events_statements_current Table">
       <code class="literal">
        events_statements_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
      <a class="link" href="performance-schema-prepared-statements-instances-table.html" title="29.12.6.4 The prepared_statements_instances Table">
       <code class="literal">
        prepared_statements_instances
       </code>
      </a>
      table does not have these columns.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SUM_
       <em class="replaceable">
        <code>
         xxx
        </code>
       </em>
      </code>
     </p>
     <p>
      The aggregate of the corresponding
      <em class="replaceable">
       <code>
        xxx
       </code>
      </em>
      column in the
      <a class="link" href="performance-schema-events-statements-current-table.html" title="29.12.6.1 The events_statements_current Table">
       <code class="literal">
        events_statements_current
       </code>
      </a>
      table. For example, the
      <code class="literal">
       SUM_LOCK_TIME
      </code>
      and
      <code class="literal">
       SUM_ERRORS
      </code>
      columns in statement
              summary tables are the aggregates of the
      <code class="literal">
       LOCK_TIME
      </code>
      and
      <code class="literal">
       ERRORS
      </code>
      columns in
      <a class="link" href="performance-schema-events-statements-current-table.html" title="29.12.6.1 The events_statements_current Table">
       <code class="literal">
        events_statements_current
       </code>
      </a>
      table.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       MAX_CONTROLLED_MEMORY
      </code>
     </p>
     <p>
      Reports the maximum amount of controlled memory used by a
              statement during execution.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       MAX_TOTAL_MEMORY
      </code>
     </p>
     <p>
      Reports the maximum amount of memory used by a statement
              during execution.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_SECONDARY
      </code>
     </p>
     <p>
      The number of times a query was processed on the
      <code class="literal">
       SECONDARY
      </code>
      engine. For use with HeatWave Service
              and HeatWave, where the
      <code class="literal">
       PRIMARY
      </code>
      engine
              is
      <code class="literal">
       InnoDB
      </code>
      and the
      <code class="literal">
       SECONDARY
      </code>
      engine is HeatWave
              (
      <code class="literal">
       RAPID
      </code>
      ). For MySQL Community Edition Server, MySQL Enterprise Edition Server
              (on-premise), and HeatWave Service without HeatWave, queries are
              always processed on the
      <code class="literal">
       PRIMARY
      </code>
      engine,
              which means the value is always 0 on these MySQL Servers.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
    <code class="literal">
     events_statements_summary_by_digest
    </code>
   </a>
   table has these additional summary columns:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       FIRST_SEEN
      </code>
      ,
      <code class="literal">
       LAST_SEEN
      </code>
     </p>
     <p>
      Timestamps indicating when statements with the given
              digest value were first seen and most recently seen.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       QUANTILE_95
      </code>
      : The 95th percentile of the
              statement latency, in picoseconds. This percentile is a
              high estimate, computed from the histogram data collected.
              In other words, for a given digest, 95% of the statements
              measured have a latency lower than
      <code class="literal">
       QUANTILE_95
      </code>
      .
     </p>
     <p>
      For access to the histogram data, use the tables described
              in
      <a class="xref" href="performance-schema-statement-histogram-summary-tables.html" title="29.12.20.4 Statement Histogram Summary Tables">
       Section 29.12.20.4, “Statement Histogram Summary Tables”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       QUANTILE_99
      </code>
      : Similar to
      <code class="literal">
       QUANTILE_95
      </code>
      , but for the 99th
              percentile.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       QUANTILE_999
      </code>
      : Similar to
      <code class="literal">
       QUANTILE_95
      </code>
      , but for the 99.9th
              percentile.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
    <code class="literal">
     events_statements_summary_by_digest
    </code>
   </a>
   table contains the following columns. These are neither
          grouping nor summary columns; they support statement sampling:
  </p>
  <a class="indexterm" name="idm46045068856048">
  </a>
  <a class="indexterm" name="idm46045068854976">
  </a>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       QUERY_SAMPLE_TEXT
      </code>
     </p>
     <p>
      A sample SQL statement that produces the digest value in
              the row. This column enables applications to access, for a
              given digest value, a statement actually seen by the
              server that produces that digest. One use for this might
              be to run
      <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
       <code class="literal">
        EXPLAIN
       </code>
      </a>
      on the
              statement to examine the execution plan for a
              representative statement associated with a frequently
              occurring digest.
     </p>
     <p>
      When the
      <code class="literal">
       QUERY_SAMPLE_TEXT
      </code>
      column is
              assigned a value, the
      <code class="literal">
       QUERY_SAMPLE_SEEN
      </code>
      and
      <code class="literal">
       QUERY_SAMPLE_TIMER_WAIT
      </code>
      columns are
              assigned values as well.
     </p>
     <p>
      The maximum space available for statement display is 1024
              bytes by default. To change this value, set the
      <a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_sql_text_length">
       <code class="literal">
        performance_schema_max_sql_text_length
       </code>
      </a>
      system variable at server startup. (Changing this value
              affects columns in other Performance Schema tables as
              well. See
      <a class="xref" href="performance-schema-statement-digests.html" title="29.10 Performance Schema Statement Digests and Sampling">
       Section 29.10, “Performance Schema Statement Digests and Sampling”
      </a>
      .)
     </p>
     <p>
      For information about statement sampling, see
      <a class="xref" href="performance-schema-statement-digests.html" title="29.10 Performance Schema Statement Digests and Sampling">
       Section 29.10, “Performance Schema Statement Digests and Sampling”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       QUERY_SAMPLE_SEEN
      </code>
     </p>
     <p>
      A timestamp indicating when the statement in the
      <code class="literal">
       QUERY_SAMPLE_TEXT
      </code>
      column was seen.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       QUERY_SAMPLE_TIMER_WAIT
      </code>
     </p>
     <p>
      The wait time for the sample statement in the
      <code class="literal">
       QUERY_SAMPLE_TEXT
      </code>
      column.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
    <code class="literal">
     events_statements_summary_by_program
    </code>
   </a>
   table has these additional summary columns:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_STATEMENTS
      </code>
      ,
      <code class="literal">
       SUM_STATEMENTS_WAIT
      </code>
      ,
      <code class="literal">
       MIN_STATEMENTS_WAIT
      </code>
      ,
      <code class="literal">
       AVG_STATEMENTS_WAIT
      </code>
      ,
      <code class="literal">
       MAX_STATEMENTS_WAIT
      </code>
     </p>
     <p>
      Statistics about nested statements invoked during stored
              program execution.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-prepared-statements-instances-table.html" title="29.12.6.4 The prepared_statements_instances Table">
    <code class="literal">
     prepared_statements_instances
    </code>
   </a>
   table has these additional summary columns:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_EXECUTE
      </code>
      ,
      <code class="literal">
       SUM_TIMER_EXECUTE
      </code>
      ,
      <code class="literal">
       MIN_TIMER_EXECUTE
      </code>
      ,
      <code class="literal">
       AVG_TIMER_EXECUTE
      </code>
      ,
      <code class="literal">
       MAX_TIMER_EXECUTE
      </code>
     </p>
     <p>
      Aggregated statistics for executions of the prepared
              statement.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The statement 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-transaction-summary-tables.html" title="29.12.20.5 Transaction Summary Tables">
       <code class="literal">
        events_transactions_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-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_summary_by_digest
       </code>
      </a>
      :
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         Primary key on (
         <code class="literal">
          SCHEMA_NAME
         </code>
         ,
         <code class="literal">
          DIGEST
         </code>
         )
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-transaction-summary-tables.html" title="29.12.20.5 Transaction Summary Tables">
       <code class="literal">
        events_transactions_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-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_summary_by_program
       </code>
      </a>
      :
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         Primary key on (
         <code class="literal">
          OBJECT_TYPE
         </code>
         ,
         <code class="literal">
          OBJECT_SCHEMA
         </code>
         ,
         <code class="literal">
          OBJECT_NAME
         </code>
         )
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_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-transaction-summary-tables.html" title="29.12.20.5 Transaction Summary Tables">
       <code class="literal">
        events_transactions_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-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_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
          statement summary tables. It has these effects:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      For
      <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
       <code class="literal">
        events_statements_summary_by_digest
       </code>
      </a>
      ,
              it removes the rows.
     </p>
    </li>
    <li class="listitem">
     <p>
      For other 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 other 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 statement 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-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
    <code class="literal">
     events_statements_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>
  <p>
   In addition, truncating
   <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
    <code class="literal">
     events_statements_summary_by_digest
    </code>
   </a>
   implicitly truncates
   <a class="link" href="performance-schema-statement-histogram-summary-tables.html" title="29.12.20.4 Statement Histogram Summary Tables">
    <code class="literal">
     events_statements_histogram_by_digest
    </code>
   </a>
   ,
          and truncating
   <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
    <code class="literal">
     events_statements_summary_global_by_event_name
    </code>
   </a>
   implicitly truncates
   <a class="link" href="performance-schema-statement-histogram-summary-tables.html" title="29.12.20.4 Statement Histogram Summary Tables">
    <code class="literal">
     events_statements_histogram_global
    </code>
   </a>
   .
  </p>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="statement-summary-tables-aggregation">
       </a>
       Statement Digest Aggregation Rules
      </h5>
     </div>
    </div>
   </div>
   <p>
    If the
    <code class="literal">
     statements_digest
    </code>
    consumer is
            enabled, aggregation into
    <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
     <code class="literal">
      events_statements_summary_by_digest
     </code>
    </a>
    occurs as follows when a statement completes. Aggregation is
            based on the
    <code class="literal">
     DIGEST
    </code>
    value computed for
            the statement.
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       If a
       <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
        <code class="literal">
         events_statements_summary_by_digest
        </code>
       </a>
       row already exists with the digest value for the
                statement that just completed, statistics for the
                statement are aggregated to that row. The
       <code class="literal">
        LAST_SEEN
       </code>
       column is updated to the
                current time.
      </p>
     </li>
     <li class="listitem">
      <p>
       If no row has the digest value for the statement that
                just completed, and the table is not full, a new row is
                created for the statement. The
       <code class="literal">
        FIRST_SEEN
       </code>
       and
       <code class="literal">
        LAST_SEEN
       </code>
       columns are initialized
                with the current time.
      </p>
     </li>
     <li class="listitem">
      <p>
       If no row has the statement digest value for the
                statement that just completed, and the table is full,
                the statistics for the statement that just completed are
                added to a special
       <span class="quote">
        “
        <span class="quote">
         catch-all
        </span>
        ”
       </span>
       row with
       <code class="literal">
        DIGEST
       </code>
       =
       <code class="literal">
        NULL
       </code>
       ,
                which is created if necessary. If the row is created,
                the
       <code class="literal">
        FIRST_SEEN
       </code>
       and
       <code class="literal">
        LAST_SEEN
       </code>
       columns are initialized
                with the current time. Otherwise, the
       <code class="literal">
        LAST_SEEN
       </code>
       column is updated with the
                current time.
      </p>
     </li>
    </ul>
   </div>
   <p>
    The row with
    <code class="literal">
     DIGEST
    </code>
    =
    <code class="literal">
     NULL
    </code>
    is maintained because Performance
            Schema tables have a maximum size due to memory constraints.
            The
    <code class="literal">
     DIGEST
    </code>
    =
    <code class="literal">
     NULL
    </code>
    row
            permits digests that do not match other rows to be counted
            even if the summary table is full, using a common
    <span class="quote">
     “
     <span class="quote">
      other
     </span>
     ”
    </span>
    bucket. This row helps you estimate
            whether the digest summary is representative:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       A
       <code class="literal">
        DIGEST
       </code>
       =
       <code class="literal">
        NULL
       </code>
       row that has a
       <code class="literal">
        COUNT_STAR
       </code>
       value that
                represents 5% of all digests shows that the digest
                summary table is very representative; the other rows
                cover 95% of the statements seen.
      </p>
     </li>
     <li class="listitem">
      <p>
       A
       <code class="literal">
        DIGEST
       </code>
       =
       <code class="literal">
        NULL
       </code>
       row that has a
       <code class="literal">
        COUNT_STAR
       </code>
       value that
                represents 50% of all digests shows that the digest
                summary table is not very representative; the other rows
                cover only half the statements seen. Most likely the DBA
                should increase the maximum table size so that more of
                the rows counted in the
       <code class="literal">
        DIGEST
       </code>
       =
       <code class="literal">
        NULL
       </code>
       row would be counted using more
                specific rows instead. By default, the table is
                autosized, but if this size is too small, set the
       <a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_digests_size">
        <code class="literal">
         performance_schema_digests_size
        </code>
       </a>
       system variable to a larger value at server startup.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="statement-summary-tables-stored-programs">
       </a>
       Stored Program Instrumentation Behavior
      </h5>
     </div>
    </div>
   </div>
   <p>
    For stored program types for which instrumentation is
            enabled in the
    <a class="link" href="performance-schema-setup-objects-table.html" title="29.12.2.4 The setup_objects Table">
     <code class="literal">
      setup_objects
     </code>
    </a>
    table,
    <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
     <code class="literal">
      events_statements_summary_by_program
     </code>
    </a>
    maintains statistics for stored programs as follows:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       A row is added for an object when it is first used in
                the server.
      </p>
     </li>
     <li class="listitem">
      <p>
       The row for an object is removed when the object is
                dropped.
      </p>
     </li>
     <li class="listitem">
      <p>
       Statistics are aggregated in the row for an object as it
                executes.
      </p>
     </li>
    </ul>
   </div>
   <p>
    See also
    <a class="xref" href="performance-schema-pre-filtering.html" title="29.4.3 Event Pre-Filtering">
     Section 29.4.3, “Event Pre-Filtering”
    </a>
    .
   </p>
  </div>
 </div>
 <br/>
</div>
