<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="key-space">
      </a>
      18.2.2 Space Needed for Keys
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045148150736">
  </a>
  <p>
   <code class="literal">
    MyISAM
   </code>
   tables use B-tree indexes. You can
      roughly calculate the size for the index file as
   <code class="literal">
    (key_length+4)/0.67
   </code>
   , summed over all keys. This
      is for the worst case when all keys are inserted in sorted order
      and the table doesn't have any compressed keys.
  </p>
  <p>
   String indexes are space compressed. If the first index part is a
      string, it is also prefix compressed. Space compression makes the
      index file smaller than the worst-case figure if a string column
      has a lot of trailing space or is a
   <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
    <code class="literal">
     VARCHAR
    </code>
   </a>
   column that is not always
      used to the full length. Prefix compression is used on keys that
      start with a string. Prefix compression helps if there are many
      strings with an identical prefix.
  </p>
  <p>
   In
   <code class="literal">
    MyISAM
   </code>
   tables, you can also prefix compress
      numbers by specifying the
   <code class="literal">
    PACK_KEYS=1
   </code>
   table
      option when you create the table. Numbers are stored with the high
      byte first, so this helps when you have many integer keys that
      have an identical prefix.
  </p>
 </div>
 <br/>
</div>
