<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="midpoint-insertion">
      </a>
      10.10.2.3 Midpoint Insertion Strategy
     </h4>
    </div>
   </div>
  </div>
  <p>
   By default, the key cache management system uses a simple LRU
          strategy for choosing key cache blocks to be evicted, but it
          also supports a more sophisticated method called the
   <span class="firstterm">
    midpoint insertion
          strategy.
   </span>
  </p>
  <p>
   When using the midpoint insertion strategy, the LRU chain is
          divided into two parts: a hot sublist and a warm sublist. The
          division point between two parts is not fixed, but the key
          cache management system takes care that the warm part is not
   <span class="quote">
    “
    <span class="quote">
     too short,
    </span>
    ”
   </span>
   always containing at least
   <a class="link" href="server-system-variables.html#sysvar_key_cache_division_limit">
    <code class="literal">
     key_cache_division_limit
    </code>
   </a>
   percent of the key cache blocks.
   <a class="link" href="server-system-variables.html#sysvar_key_cache_division_limit">
    <code class="literal">
     key_cache_division_limit
    </code>
   </a>
   is a
          component of structured key cache variables, so its value is a
          parameter that can be set per cache.
  </p>
  <p>
   When an index block is read from a table into the key cache,
          it is placed at the end of the warm sublist. After a certain
          number of hits (accesses of the block), it is promoted to the
          hot sublist. At present, the number of hits required to
          promote a block (3) is the same for all index blocks.
  </p>
  <p>
   A block promoted into the hot sublist is placed at the end of
          the list. The block then circulates within this sublist. If
          the block stays at the beginning of the sublist for a long
          enough time, it is demoted to the warm sublist. This time is
          determined by the value of the
   <a class="link" href="server-system-variables.html#sysvar_key_cache_age_threshold">
    <code class="literal">
     key_cache_age_threshold
    </code>
   </a>
   component of the key cache.
  </p>
  <p>
   The threshold value prescribes that, for a key cache
          containing
   <em class="replaceable">
    <code>
     N
    </code>
   </em>
   blocks, the block at
          the beginning of the hot sublist not accessed within the last
   <code class="literal">
    <em class="replaceable">
     <code>
      N
     </code>
    </em>
    *
          key_cache_age_threshold / 100
   </code>
   hits is to be moved to
          the beginning of the warm sublist. It then becomes the first
          candidate for eviction, because blocks for replacement always
          are taken from the beginning of the warm sublist.
  </p>
  <p>
   The midpoint insertion strategy enables you to keep
          more-valued blocks always in the cache. If you prefer to use
          the plain LRU strategy, leave the
   <a class="link" href="server-system-variables.html#sysvar_key_cache_division_limit">
    <code class="literal">
     key_cache_division_limit
    </code>
   </a>
   value set to its default of 100.
  </p>
  <p>
   The midpoint insertion strategy helps to improve performance
          when execution of a query that requires an index scan
          effectively pushes out of the cache all the index blocks
          corresponding to valuable high-level B-tree nodes. To avoid
          this, you must use a midpoint insertion strategy with the
   <a class="link" href="server-system-variables.html#sysvar_key_cache_division_limit">
    <code class="literal">
     key_cache_division_limit
    </code>
   </a>
   set
          to much less than 100. Then valuable frequently hit nodes are
          preserved in the hot sublist during an index scan operation as
          well.
  </p>
 </div>
 <br/>
</div>
