<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="performance-schema-memory-summary-tables">
      </a>
      29.12.20.10 Memory Summary Tables
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045068181632">
  </a>
  <a class="indexterm" name="idm46045068180176">
  </a>
  <a class="indexterm" name="idm46045068178656">
  </a>
  <a class="indexterm" name="idm46045068177136">
  </a>
  <a class="indexterm" name="idm46045068175616">
  </a>
  <a class="indexterm" name="idm46045068174096">
  </a>
  <a class="indexterm" name="idm46045068172576">
  </a>
  <a class="indexterm" name="idm46045068171056">
  </a>
  <a class="indexterm" name="idm46045068169536">
  </a>
  <a class="indexterm" name="idm46045068168016">
  </a>
  <p>
   The Performance Schema instruments memory usage and aggregates
          memory usage statistics, detailed by these factors:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Type of memory used (various caches, internal buffers, and
              so forth)
     </p>
    </li>
    <li class="listitem">
     <p>
      Thread, account, user, host indirectly performing the
              memory operation
     </p>
    </li>
   </ul>
  </div>
  <p>
   The Performance Schema instruments the following aspects of
          memory use
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Memory sizes used
     </p>
    </li>
    <li class="listitem">
     <p>
      Operation counts
     </p>
    </li>
    <li class="listitem">
     <p>
      Low and high water marks
     </p>
    </li>
   </ul>
  </div>
  <p>
   Memory sizes help to understand or tune the memory consumption
          of the server.
  </p>
  <p>
   Operation counts help to understand or tune the overall
          pressure the server is putting on the memory allocator, which
          has an impact on performance. Allocating a single byte one
          million times is not the same as allocating one million bytes
          a single time; tracking both sizes and counts can expose the
          difference.
  </p>
  <p>
   Low and high water marks are critical to detect workload
          spikes, overall workload stability, and possible memory leaks.
  </p>
  <p>
   Memory summary tables do not contain timing information
          because memory events are not timed.
  </p>
  <p>
   For information about collecting memory usage data, see
   <a class="xref" href="performance-schema-memory-summary-tables.html#memory-instrumentation-behavior" title="Memory Instrumentation Behavior">
    Memory Instrumentation Behavior
   </a>
   .
  </p>
  <p>
   Example memory event summary information:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa55288007"><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>memory_summary_global_by_event_name
       <span class="token keyword">WHERE</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/sql/TABLE'</span>\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> memory/sql/TABLE
                 COUNT_ALLOC<span class="token punctuation">:</span> 1381
                  COUNT_FREE<span class="token punctuation">:</span> 924
   SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">:</span> 2059873
    SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">:</span> 1407432
              LOW_COUNT_USED<span class="token punctuation">:</span> 0
          CURRENT_COUNT_USED<span class="token punctuation">:</span> 457
             HIGH_COUNT_USED<span class="token punctuation">:</span> 461
    LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 0
CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 652441
   HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 669269</span></code></pre>
  </div>
  <p>
   Each memory 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-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
       <code class="literal">
        memory_summary_by_account_by_event_name
       </code>
      </a>
      has
      <code class="literal">
       USER
      </code>
      ,
      <code class="literal">
       HOST
      </code>
      , and
      <code class="literal">
       EVENT_NAME
      </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-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
       <code class="literal">
        memory_summary_by_host_by_event_name
       </code>
      </a>
      has
      <code class="literal">
       HOST
      </code>
      and
      <code class="literal">
       EVENT_NAME
      </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-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
       <code class="literal">
        memory_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-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
       <code class="literal">
        memory_summary_by_user_by_event_name
       </code>
      </a>
      has
      <code class="literal">
       USER
      </code>
      and
      <code class="literal">
       EVENT_NAME
      </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-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
       <code class="literal">
        memory_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 memory 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">
       COUNT_ALLOC
      </code>
      ,
      <code class="literal">
       COUNT_FREE
      </code>
     </p>
     <p>
      The aggregated numbers of calls to memory-allocation and
              memory-free functions.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SUM_NUMBER_OF_BYTES_ALLOC
      </code>
      ,
      <code class="literal">
       SUM_NUMBER_OF_BYTES_FREE
      </code>
     </p>
     <p>
      The aggregated sizes of allocated and freed memory blocks.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       CURRENT_COUNT_USED
      </code>
     </p>
     <p>
      The aggregated number of currently allocated blocks that
              have not been freed yet. This is a convenience column,
              equal to
      <code class="literal">
       COUNT_ALLOC
      </code>
      −
      <code class="literal">
       COUNT_FREE
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       CURRENT_NUMBER_OF_BYTES_USED
      </code>
     </p>
     <p>
      The aggregated size of currently allocated memory blocks
              that have not been freed yet. This is a convenience
              column, equal to
      <code class="literal">
       SUM_NUMBER_OF_BYTES_ALLOC
      </code>
      −
      <code class="literal">
       SUM_NUMBER_OF_BYTES_FREE
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       LOW_COUNT_USED
      </code>
      ,
      <code class="literal">
       HIGH_COUNT_USED
      </code>
     </p>
     <p>
      The low and high water marks corresponding to the
      <code class="literal">
       CURRENT_COUNT_USED
      </code>
      column.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       LOW_NUMBER_OF_BYTES_USED
      </code>
      ,
      <code class="literal">
       HIGH_NUMBER_OF_BYTES_USED
      </code>
     </p>
     <p>
      The low and high water marks corresponding to the
      <code class="literal">
       CURRENT_NUMBER_OF_BYTES_USED
      </code>
      column.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The memory 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-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
       <code class="literal">
        memory_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-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
       <code class="literal">
        memory_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-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
       <code class="literal">
        memory_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-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
       <code class="literal">
        memory_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-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
       <code class="literal">
        memory_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
          memory summary tables. It has these effects:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      In general, truncation resets the baseline for statistics,
              but does not change the server state. That is, truncating
              a memory table does not free memory.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_ALLOC
      </code>
      and
      <code class="literal">
       COUNT_FREE
      </code>
      are reset to a new baseline,
              by reducing each counter by the same value.
     </p>
    </li>
    <li class="listitem">
     <p>
      Likewise,
      <code class="literal">
       SUM_NUMBER_OF_BYTES_ALLOC
      </code>
      and
      <code class="literal">
       SUM_NUMBER_OF_BYTES_FREE
      </code>
      are reset to a
              new baseline.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       LOW_COUNT_USED
      </code>
      and
      <code class="literal">
       HIGH_COUNT_USED
      </code>
      are reset to
      <code class="literal">
       CURRENT_COUNT_USED
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       LOW_NUMBER_OF_BYTES_USED
      </code>
      and
      <code class="literal">
       HIGH_NUMBER_OF_BYTES_USED
      </code>
      are reset to
      <code class="literal">
       CURRENT_NUMBER_OF_BYTES_USED
      </code>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   In addition, each memory 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-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
    <code class="literal">
     memory_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 class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="memory-instrumentation-behavior">
       </a>
       Memory Instrumentation Behavior
      </h5>
     </div>
    </div>
   </div>
   <p>
    Memory instruments are listed 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 and
            have names of the form
    <code class="literal">
     memory/
     <em class="replaceable">
      <code>
       code_area
      </code>
     </em>
     /
     <em class="replaceable">
      <code>
       instrument_name
      </code>
     </em>
    </code>
    .
            Memory instrumentation is enabled by default.
   </p>
   <p>
    Instruments named with the prefix
    <code class="literal">
     memory/performance_schema/
    </code>
    expose how
            much memory is allocated for internal buffers in the
            Performance Schema itself. The
    <code class="literal">
     memory/performance_schema/
    </code>
    instruments
            are built in, always enabled, and cannot be disabled at
            startup or runtime. Built-in memory instruments are
            displayed only in the
    <a class="link" href="performance-schema-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
     <code class="literal">
      memory_summary_global_by_event_name
     </code>
    </a>
    table.
   </p>
   <p>
    To control memory instrumentation state 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="sa53367503"><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>'memory/%=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="sa53359468"><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>'memory/%=OFF'</span></code></pre>
      </div>
     </li>
    </ul>
   </div>
   <p>
    To control memory instrumentation state at runtime, update
            the
    <code class="literal">
     ENABLED
    </code>
    column of the relevant
            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>
       Enable:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89918947"><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">LIKE</span> <span class="token string">'memory/%'</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="sa10096496"><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 keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'memory/%'</span><span class="token punctuation">;</span></code></pre>
      </div>
     </li>
    </ul>
   </div>
   <p>
    For memory instruments, the
    <code class="literal">
     TIMED
    </code>
    column
            in
    <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>
    is ignored
            because memory operations are not timed.
   </p>
   <p>
    When a thread in the server executes a memory allocation
            that has been instrumented, these rules apply:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       If the thread is not instrumented or the memory
                instrument is not enabled, the memory block allocated is
                not instrumented.
      </p>
     </li>
     <li class="listitem">
      <p>
       Otherwise (that is, both the thread and the instrument
                are enabled), the memory block allocated is
                instrumented.
      </p>
     </li>
    </ul>
   </div>
   <p>
    For deallocation, these rules apply:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       If a memory allocation operation was instrumented, the
                corresponding free operation is instrumented, regardless
                of the current instrument or thread enabled status.
      </p>
     </li>
     <li class="listitem">
      <p>
       If a memory allocation operation was not instrumented,
                the corresponding free operation is not instrumented,
                regardless of the current instrument or thread enabled
                status.
      </p>
     </li>
    </ul>
   </div>
   <p>
    For the per-thread statistics, the following rules apply.
   </p>
   <p>
    When an instrumented memory block of size
    <em class="replaceable">
     <code>
      N
     </code>
    </em>
    is allocated, the Performance
            Schema makes these updates to memory summary table columns:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        COUNT_ALLOC
       </code>
       : Increased by 1
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        CURRENT_COUNT_USED
       </code>
       : Increased by 1
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        HIGH_COUNT_USED
       </code>
       : Increased if
       <code class="literal">
        CURRENT_COUNT_USED
       </code>
       is a new maximum
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        SUM_NUMBER_OF_BYTES_ALLOC
       </code>
       : Increased
                by
       <em class="replaceable">
        <code>
         N
        </code>
       </em>
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        CURRENT_NUMBER_OF_BYTES_USED
       </code>
       :
                Increased by
       <em class="replaceable">
        <code>
         N
        </code>
       </em>
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        HIGH_NUMBER_OF_BYTES_USED
       </code>
       : Increased
                if
       <code class="literal">
        CURRENT_NUMBER_OF_BYTES_USED
       </code>
       is a
                new maximum
      </p>
     </li>
    </ul>
   </div>
   <p>
    When an instrumented memory block is deallocated, the
            Performance Schema makes these updates to memory summary
            table columns:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        COUNT_FREE
       </code>
       : Increased by 1
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        CURRENT_COUNT_USED
       </code>
       : Decreased by 1
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        LOW_COUNT_USED
       </code>
       : Decreased if
       <code class="literal">
        CURRENT_COUNT_USED
       </code>
       is a new minimum
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        SUM_NUMBER_OF_BYTES_FREE
       </code>
       : Increased
                by
       <em class="replaceable">
        <code>
         N
        </code>
       </em>
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        CURRENT_NUMBER_OF_BYTES_USED
       </code>
       :
                Decreased by
       <em class="replaceable">
        <code>
         N
        </code>
       </em>
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        LOW_NUMBER_OF_BYTES_USED
       </code>
       : Decreased
                if
       <code class="literal">
        CURRENT_NUMBER_OF_BYTES_USED
       </code>
       is a
                new minimum
      </p>
     </li>
    </ul>
   </div>
   <p>
    For higher-level aggregates (global, by account, by user, by
            host), the same rules apply as expected for low and high
            water marks.
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        LOW_COUNT_USED
       </code>
       and
       <code class="literal">
        LOW_NUMBER_OF_BYTES_USED
       </code>
       are lower
                estimates. The value reported by the Performance Schema
                is guaranteed to be less than or equal to the lowest
                count or size of memory effectively used at runtime.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        HIGH_COUNT_USED
       </code>
       and
       <code class="literal">
        HIGH_NUMBER_OF_BYTES_USED
       </code>
       are higher
                estimates. The value reported by the Performance Schema
                is guaranteed to be greater than or equal to the highest
                count or size of memory effectively used at runtime.
      </p>
     </li>
    </ul>
   </div>
   <p>
    For lower estimates in summary tables other than
    <a class="link" href="performance-schema-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
     <code class="literal">
      memory_summary_global_by_event_name
     </code>
    </a>
    ,
            it is possible for values to go negative if memory ownership
            is transferred between threads.
   </p>
   <p>
    Here is an example of estimate computation; but note that
            estimate implementation is subject to change:
   </p>
   <p>
    Thread 1 uses memory in the range from 1MB to 2MB during
            execution, as reported by the
    <code class="literal">
     LOW_NUMBER_OF_BYTES_USED
    </code>
    and
    <code class="literal">
     HIGH_NUMBER_OF_BYTES_USED
    </code>
    columns of the
    <a class="link" href="performance-schema-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
     <code class="literal">
      memory_summary_by_thread_by_event_name
     </code>
    </a>
    table.
   </p>
   <p>
    Thread 2 uses memory in the range from 10MB to 12MB during
            execution, as reported likewise.
   </p>
   <p>
    When these two threads belong to the same user account, the
            per-account summary estimates that this account used memory
            in the range from 11MB to 14MB. That is, the
    <code class="literal">
     LOW_NUMBER_OF_BYTES_USED
    </code>
    for the higher
            level aggregate is the sum of each
    <code class="literal">
     LOW_NUMBER_OF_BYTES_USED
    </code>
    (assuming the
            worst case). Likewise, the
    <code class="literal">
     HIGH_NUMBER_OF_BYTES_USED
    </code>
    for the higher
            level aggregate is the sum of each
    <code class="literal">
     HIGH_NUMBER_OF_BYTES_USED
    </code>
    (assuming the
            worst case).
   </p>
   <p>
    11MB is a lower estimate that can occur only if both threads
            hit the low usage mark at the same time.
   </p>
   <p>
    14MB is a higher estimate that can occur only if both
            threads hit the high usage mark at the same time.
   </p>
   <p>
    The real memory usage for this account could have been in
            the range from 11.5MB to 13.5MB.
   </p>
   <p>
    For capacity planning, reporting the worst case is actually
            the desired behavior, as it shows what can potentially
            happen when sessions are uncorrelated, which is typically
            the case.
   </p>
  </div>
 </div>
 <br/>
</div>
