<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="load-index">
      </a>
      15.7.8.5 LOAD INDEX INTO CACHE Statement
     </h4>
    </div>
   </div>
  </div>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa14248093"><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">LOAD</span> <span class="token keyword">INDEX</span> <span class="token keyword">INTO</span> <span class="token keyword">CACHE</span>
  <em class="replaceable">tbl_index_list</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">tbl_index_list</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>

<em class="replaceable">tbl_index_list</em>:
  <em class="replaceable">tbl_name</em>
    <span class="token punctuation">[</span><span class="token keyword">PARTITION</span> <span class="token punctuation">(</span><em class="replaceable">partition_list</em><span class="token punctuation">)</span><span class="token punctuation">]</span>
    <span class="token punctuation">[</span>{<span class="token keyword">INDEX</span><span class="token operator">|</span><span class="token keyword">KEY</span>} <span class="token punctuation">(</span><em class="replaceable">index_name</em><span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">index_name</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">IGNORE</span> <span class="token keyword">LEAVES</span><span class="token punctuation">]</span>

<em class="replaceable">partition_list</em>: {
    <em class="replaceable">partition_name</em><span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">partition_name</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
  <span class="token operator">|</span> <span class="token keyword">ALL</span>
}</code></pre>
  </div>
  <p>
   The
   <a class="link" href="load-index.html" title="15.7.8.5 LOAD INDEX INTO CACHE Statement">
    <code class="literal">
     LOAD INDEX INTO
        CACHE
    </code>
   </a>
   statement preloads a table index into the key
        cache to which it has been assigned by an explicit
   <a class="link" href="cache-index.html" title="15.7.8.2 CACHE INDEX Statement">
    <code class="literal">
     CACHE INDEX
    </code>
   </a>
   statement, or into
        the default key cache otherwise.
  </p>
  <p>
   <a class="link" href="load-index.html" title="15.7.8.5 LOAD INDEX INTO CACHE Statement">
    <code class="literal">
     LOAD INDEX INTO
        CACHE
    </code>
   </a>
   applies only to
   <code class="literal">
    MyISAM
   </code>
   tables, including partitioned
   <code class="literal">
    MyISAM
   </code>
   tables.
        In addition, indexes on partitioned tables can be preloaded for
        one, several, or all partitions.
  </p>
  <p>
   The
   <code class="literal">
    IGNORE LEAVES
   </code>
   modifier causes only blocks
        for the nonleaf nodes of the index to be preloaded.
  </p>
  <p>
   <code class="literal">
    IGNORE LEAVES
   </code>
   is also supported for
        partitioned
   <code class="literal">
    MyISAM
   </code>
   tables.
  </p>
  <p>
   The following statement preloads nodes (index blocks) of indexes
        for the tables
   <code class="literal">
    t1
   </code>
   and
   <code class="literal">
    t2
   </code>
   :
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa95045449"><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">LOAD</span> <span class="token keyword">INDEX</span> <span class="token keyword">INTO</span> <span class="token keyword">CACHE</span> t1<span class="token punctuation">,</span> t2 <span class="token keyword">IGNORE</span> <span class="token keyword">LEAVES</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Table   <span class="token punctuation">|</span> Op           <span class="token punctuation">|</span> Msg_type <span class="token punctuation">|</span> Msg_text <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> test.t1 <span class="token punctuation">|</span> preload_keys <span class="token punctuation">|</span> status   <span class="token punctuation">|</span> OK       <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> test.t2 <span class="token punctuation">|</span> preload_keys <span class="token punctuation">|</span> status   <span class="token punctuation">|</span> OK       <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
  </div>
  <p>
   This statement preloads all index blocks from
   <code class="literal">
    t1
   </code>
   . It preloads only blocks for the nonleaf
        nodes from
   <code class="literal">
    t2
   </code>
   .
  </p>
  <p>
   The syntax of
   <a class="link" href="load-index.html" title="15.7.8.5 LOAD INDEX INTO CACHE Statement">
    <code class="literal">
     LOAD
        INDEX INTO CACHE
    </code>
   </a>
   enables you to specify that only
        particular indexes from a table should be preloaded. However,
        the implementation preloads all the table's indexes into the
        cache, so there is no reason to specify anything other than the
        table name.
  </p>
  <p>
   It is possible to preload indexes on specific partitions of
        partitioned
   <code class="literal">
    MyISAM
   </code>
   tables. For example, of
        the following 2 statements, the first preloads indexes for
        partition
   <code class="literal">
    p0
   </code>
   of a partitioned table
   <code class="literal">
    pt
   </code>
   , while the second preloads the indexes for
        partitions
   <code class="literal">
    p1
   </code>
   and
   <code class="literal">
    p3
   </code>
   of
        the same table:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa81793512"><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">LOAD</span> <span class="token keyword">INDEX</span> <span class="token keyword">INTO</span> <span class="token keyword">CACHE</span> pt <span class="token keyword">PARTITION</span> <span class="token punctuation">(</span>p0<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">LOAD</span> <span class="token keyword">INDEX</span> <span class="token keyword">INTO</span> <span class="token keyword">CACHE</span> pt <span class="token keyword">PARTITION</span> <span class="token punctuation">(</span>p1<span class="token punctuation">,</span> p3<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   To preload the indexes for all partitions in table
   <code class="literal">
    pt
   </code>
   , you can use either of the following two
        statements:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa84609747"><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">LOAD</span> <span class="token keyword">INDEX</span> <span class="token keyword">INTO</span> <span class="token keyword">CACHE</span> pt <span class="token keyword">PARTITION</span> <span class="token punctuation">(</span><span class="token keyword">ALL</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">LOAD</span> <span class="token keyword">INDEX</span> <span class="token keyword">INTO</span> <span class="token keyword">CACHE</span> pt<span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   The two statements just shown are equivalent, and issuing either
        one has exactly the same effect. In other words, if you wish to
        preload indexes for all partitions of a partitioned table, the
   <code class="literal">
    PARTITION (ALL)
   </code>
   clause is optional.
  </p>
  <p>
   When preloading indexes for multiple partitions, the partitions
        need not be contiguous, and you need not list their names in any
        particular order.
  </p>
  <p>
   <a class="link" href="load-index.html" title="15.7.8.5 LOAD INDEX INTO CACHE Statement">
    <code class="literal">
     LOAD INDEX INTO
        CACHE ... IGNORE LEAVES
    </code>
   </a>
   fails unless all indexes in a
        table have the same block size. To determine index block sizes
        for a table, use
   <a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
    <span class="command">
     <strong>
      myisamchk -dv
     </strong>
    </span>
   </a>
   and check the
   <code class="literal">
    Blocksize
   </code>
   column.
  </p>
 </div>
 <br/>
</div>
