<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="key-cache-restructuring">
      </a>
      10.10.2.6 Restructuring a Key Cache
     </h4>
    </div>
   </div>
  </div>
  <p>
   A key cache can be restructured at any time by updating its
          parameter values. For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa6346368"><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">SET</span> <span class="token keyword">GLOBAL</span> cold_cache<span class="token punctuation">.</span>key_buffer_size<span class="token operator">=</span><span class="token number">4</span><span class="token operator">*</span><span class="token number">1024</span><span class="token operator">*</span><span class="token number">1024</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   If you assign to either the
   <a class="link" href="server-system-variables.html#sysvar_key_buffer_size">
    <code class="literal">
     key_buffer_size
    </code>
   </a>
   or
   <a class="link" href="server-system-variables.html#sysvar_key_cache_block_size">
    <code class="literal">
     key_cache_block_size
    </code>
   </a>
   key
          cache component a value that differs from the component's
          current value, the server destroys the cache's old
          structure and creates a new one based on the new values. If
          the cache contains any dirty blocks, the server saves them to
          disk before destroying and re-creating the cache.
          Restructuring does not occur if you change other key cache
          parameters.
  </p>
  <p>
   When restructuring a key cache, the server first flushes the
          contents of any dirty buffers to disk. After that, the cache
          contents become unavailable. However, restructuring does not
          block queries that need to use indexes assigned to the cache.
          Instead, the server directly accesses the table indexes using
          native file system caching. File system caching is not as
          efficient as using a key cache, so although queries execute, a
          slowdown can be anticipated. After the cache has been
          restructured, it becomes available again for caching indexes
          assigned to it, and the use of file system caching for the
          indexes ceases.
  </p>
 </div>
 <br/>
</div>
