<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="performance-schema-statement-histogram-summary-tables">
      </a>
      29.12.20.4 Statement Histogram Summary Tables
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045068734656">
  </a>
  <a class="indexterm" name="idm46045068733200">
  </a>
  <a class="indexterm" name="idm46045068731680">
  </a>
  <a class="indexterm" name="idm46045068730160">
  </a>
  <p>
   The Performance Schema maintains statement event summary
          tables that contain information about minimum, maximum, and
          average statement latency (see
   <a class="xref" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
    Section 29.12.20.3, “Statement Summary Tables”
   </a>
   ).
          Those tables permit high-level assessment of system
          performance. To permit assessment at a more fine-grained
          level, the Performance Schema also collects histogram data for
          statement latencies. These histograms provide additional
          insight into latency distributions.
  </p>
  <p>
   <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 histogram information:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa5621459"><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_histogram_by_digest
       <span class="token keyword">WHERE</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token operator">=</span> <span class="token string">'mydb'</span> <span class="token operator">AND</span> DIGEST <span class="token operator">=</span> <span class="token string">'bb3f69453119b2d7b3ae40673a9d4c7c'</span>
       <span class="token operator">AND</span> COUNT_BUCKET <span class="token operator">&gt;</span> <span class="token number">0</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> BUCKET_NUMBER\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>
           SCHEMA_NAME<span class="token punctuation">:</span> mydb
                DIGEST<span class="token punctuation">:</span> bb3f69453119b2d7b3ae40673a9d4c7c
         BUCKET_NUMBER<span class="token punctuation">:</span> 42
      BUCKET_TIMER_LOW<span class="token punctuation">:</span> 66069344
     BUCKET_TIMER_HIGH<span class="token punctuation">:</span> 69183097
          COUNT_BUCKET<span class="token punctuation">:</span> 1
COUNT_BUCKET_AND_LOWER<span class="token punctuation">:</span> 1
       BUCKET_QUANTILE<span class="token punctuation">:</span> 0.058824
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 2. 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>
           SCHEMA_NAME<span class="token punctuation">:</span> mydb
                DIGEST<span class="token punctuation">:</span> bb3f69453119b2d7b3ae40673a9d4c7c
         BUCKET_NUMBER<span class="token punctuation">:</span> 43
      BUCKET_TIMER_LOW<span class="token punctuation">:</span> 69183097
     BUCKET_TIMER_HIGH<span class="token punctuation">:</span> 72443596
          COUNT_BUCKET<span class="token punctuation">:</span> 1
COUNT_BUCKET_AND_LOWER<span class="token punctuation">:</span> 2
       BUCKET_QUANTILE<span class="token punctuation">:</span> 0.117647
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 3. 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>
           SCHEMA_NAME<span class="token punctuation">:</span> mydb
                DIGEST<span class="token punctuation">:</span> bb3f69453119b2d7b3ae40673a9d4c7c
         BUCKET_NUMBER<span class="token punctuation">:</span> 44
      BUCKET_TIMER_LOW<span class="token punctuation">:</span> 72443596
     BUCKET_TIMER_HIGH<span class="token punctuation">:</span> 75857757
          COUNT_BUCKET<span class="token punctuation">:</span> 2
COUNT_BUCKET_AND_LOWER<span class="token punctuation">:</span> 4
       BUCKET_QUANTILE<span class="token punctuation">:</span> 0.235294
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 4. 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>
           SCHEMA_NAME<span class="token punctuation">:</span> mydb
                DIGEST<span class="token punctuation">:</span> bb3f69453119b2d7b3ae40673a9d4c7c
         BUCKET_NUMBER<span class="token punctuation">:</span> 45
      BUCKET_TIMER_LOW<span class="token punctuation">:</span> 75857757
     BUCKET_TIMER_HIGH<span class="token punctuation">:</span> 79432823
          COUNT_BUCKET<span class="token punctuation">:</span> 6
COUNT_BUCKET_AND_LOWER<span class="token punctuation">:</span> 10
       BUCKET_QUANTILE<span class="token punctuation">:</span> 0.625000
...</span></code></pre>
  </div>
  <p>
   For example, in row 3, these values indicate that 23.52% of
          queries run in under 75.86 microseconds:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa81485135"><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">BUCKET_TIMER_HIGH: <span class="token number">75857757</span>
  BUCKET_QUANTILE: <span class="token number">0.235294</span></code></pre>
  </div>
  <p>
   In row 4, these values indicate that 62.50% of queries run in
          under 79.44 microseconds:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa99075892"><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">BUCKET_TIMER_HIGH: <span class="token number">79432823</span>
  BUCKET_QUANTILE: <span class="token number">0.625000</span></code></pre>
  </div>
  <p>
   Each statement histogram summary table has one or more
          grouping columns to indicate how the table aggregates events:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <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>
      has
      <code class="literal">
       SCHEMA_NAME
      </code>
      ,
      <code class="literal">
       DIGEST
      </code>
      , and
      <code class="literal">
       BUCKET_NUMBER
      </code>
      columns:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         The
         <code class="literal">
          SCHEMA_NAME
         </code>
         and
         <code class="literal">
          DIGEST
         </code>
         columns identify a statement
                  digest row in 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.
        </p>
       </li>
       <li class="listitem">
        <p>
         The
         <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>
         rows with the same
         <code class="literal">
          SCHEMA_NAME
         </code>
         and
         <code class="literal">
          DIGEST
         </code>
         values comprise the
                  histogram for that schema/digest combination.
        </p>
       </li>
       <li class="listitem">
        <p>
         Within a given histogram, the
         <code class="literal">
          BUCKET_NUMBER
         </code>
         column indicates the
                  bucket number.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      <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>
      has a
      <code class="literal">
       BUCKET_NUMBER
      </code>
      column. This table
              summarizes latencies globally across schema name and
              digest values, using a single histogram. The
      <code class="literal">
       BUCKET_NUMBER
      </code>
      column indicates the
              bucket number within this global histogram.
     </p>
    </li>
   </ul>
  </div>
  <p>
   A histogram consists of
   <em class="replaceable">
    <code>
     N
    </code>
   </em>
   buckets,
          where each row represents one bucket, with the bucket number
          indicated by the
   <code class="literal">
    BUCKET_NUMBER
   </code>
   column.
          Bucket numbers begin with 0.
  </p>
  <p>
   Each statement histogram summary table has these summary
          columns containing aggregated values:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       BUCKET_TIMER_LOW
      </code>
      ,
      <code class="literal">
       BUCKET_TIMER_HIGH
      </code>
     </p>
     <p>
      A bucket counts statements that have a latency, in
              picoseconds, measured between
      <code class="literal">
       BUCKET_TIMER_LOW
      </code>
      and
      <code class="literal">
       BUCKET_TIMER_HIGH
      </code>
      :
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         The value of
         <code class="literal">
          BUCKET_TIMER_LOW
         </code>
         for
                  the first bucket (
         <code class="literal">
          BUCKET_NUMBER
         </code>
         =
                  0) is 0.
        </p>
       </li>
       <li class="listitem">
        <p>
         The value of
         <code class="literal">
          BUCKET_TIMER_LOW
         </code>
         for a
                  bucket (
         <code class="literal">
          BUCKET_NUMBER
         </code>
         =
         <em class="replaceable">
          <code>
           k
          </code>
         </em>
         ) is the same as
         <code class="literal">
          BUCKET_TIMER_HIGH
         </code>
         for the previous
                  bucket (
         <code class="literal">
          BUCKET_NUMBER
         </code>
         =
         <em class="replaceable">
          <code>
           k
          </code>
         </em>
         −1)
        </p>
       </li>
       <li class="listitem">
        <p>
         The last bucket is a catchall for statements that have
                  a latency exceeding previous buckets in the histogram.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_BUCKET
      </code>
     </p>
     <p>
      The number of statements measured with a latency in the
              interval from
      <code class="literal">
       BUCKET_TIMER_LOW
      </code>
      up to
              but not including
      <code class="literal">
       BUCKET_TIMER_HIGH
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_BUCKET_AND_LOWER
      </code>
     </p>
     <p>
      The number of statements measured with a latency in the
              interval from 0 up to but not including
      <code class="literal">
       BUCKET_TIMER_HIGH
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       BUCKET_QUANTILE
      </code>
     </p>
     <p>
      The proportion of statements that fall into this or a
              lower bucket. This proportion corresponds by definition to
      <code class="literal">
       COUNT_BUCKET_AND_LOWER /
              SUM(COUNT_BUCKET)
      </code>
      and is displayed as a
              convenience column.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The statement histogram 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-statement-histogram-summary-tables.html" title="29.12.20.4 Statement Histogram Summary Tables">
       <code class="literal">
        events_statements_histogram_by_digest
       </code>
      </a>
      :
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         Unique index on (
         <code class="literal">
          SCHEMA_NAME
         </code>
         ,
         <code class="literal">
          DIGEST
         </code>
         ,
         <code class="literal">
          BUCKET_NUMBER
         </code>
         )
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      <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="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         Primary key on (
         <code class="literal">
          BUCKET_NUMBER
         </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 histogram summary tables. Truncation sets the
   <code class="literal">
    COUNT_BUCKET
   </code>
   and
   <code class="literal">
    COUNT_BUCKET_AND_LOWER
   </code>
   columns to 0.
  </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>
 <br/>
</div>
