<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="delete-optimization">
      </a>
      10.2.5.3 Optimizing DELETE Statements
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045227621216">
  </a>
  <p>
   The time required to delete individual rows in a
   <code class="literal">
    MyISAM
   </code>
   table is exactly proportional to the
          number of indexes. To delete rows more quickly, you can
          increase the size of the key cache by increasing the
   <a class="link" href="server-system-variables.html#sysvar_key_buffer_size">
    <code class="literal">
     key_buffer_size
    </code>
   </a>
   system
          variable. See
   <a class="xref" href="server-configuration.html" title="7.1.1 Configuring the Server">
    Section 7.1.1, “Configuring the Server”
   </a>
   .
  </p>
  <p>
   To delete all rows from a
   <code class="literal">
    MyISAM
   </code>
   table,
   <code class="literal">
    TRUNCATE TABLE
    <em class="replaceable">
     <code>
      tbl_name
     </code>
    </em>
   </code>
   is faster than
   <code class="literal">
    DELETE FROM
    <em class="replaceable">
     <code>
      tbl_name
     </code>
    </em>
   </code>
   . Truncate
          operations are not transaction-safe; an error occurs when
          attempting one in the course of an active transaction or
          active table lock. See
   <a class="xref" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
    Section 15.1.37, “TRUNCATE TABLE Statement”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
