<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="miscellaneous-optimization-tips">
      </a>
      10.2.7 Other Optimization Tips
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045227602992">
  </a>
  <a class="indexterm" name="idm46045227601504">
  </a>
  <p>
   This section lists a number of miscellaneous tips for improving
        query processing speed:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If your application makes several database requests to
            perform related updates, combining the statements into a
            stored routine can help performance. Similarly, if your
            application computes a single result based on several column
            values or large volumes of data, combining the computation
            into a loadable function can help performance. The resulting
            fast database operations are then available to be reused by
            other queries, applications, and even code written in
            different programming languages. See
      <a class="xref" href="stored-routines.html" title="27.2 Using Stored Routines">
       Section 27.2, “Using Stored Routines”
      </a>
      and
      <a class="ulink" href="/doc/extending-mysql/8.4/en/adding-functions.html" target="_top">
       Adding Functions to MySQL
      </a>
      for more information.
     </p>
    </li>
    <li class="listitem">
     <p>
      To fix any compression issues that occur with
      <code class="literal">
       ARCHIVE
      </code>
      tables, use
      <a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
       <code class="literal">
        OPTIMIZE TABLE
       </code>
      </a>
      . See
      <a class="xref" href="archive-storage-engine.html" title="18.5 The ARCHIVE Storage Engine">
       Section 18.5, “The ARCHIVE Storage Engine”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If possible, classify reports as
      <span class="quote">
       “
       <span class="quote">
        live
       </span>
       ”
      </span>
      or as
      <span class="quote">
       “
       <span class="quote">
        statistical
       </span>
       ”
      </span>
      , where data needed for
            statistical reports is created only from summary tables that
            are generated periodically from the live data.
     </p>
    </li>
    <li class="listitem">
     <p>
      If you have data that does not conform well to a
            rows-and-columns table structure, you can pack and store
            data into a
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        BLOB
       </code>
      </a>
      column. In
            this case, you must provide code in your application to pack
            and unpack information, but this might save I/O operations
            to read and write the sets of related values.
     </p>
    </li>
    <li class="listitem">
     <p>
      With Web servers, store images and other binary assets as
            files, with the path name stored in the database rather than
            the file itself. Most Web servers are better at caching
            files than database contents, so using files is generally
            faster. (Although you must handle backups and storage issues
            yourself in this case.)
     </p>
    </li>
    <li class="listitem">
     <p>
      If you need really high speed, look at the low-level MySQL
            interfaces. For example, by accessing the MySQL
      <a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
       <code class="literal">
        InnoDB
       </code>
      </a>
      or
      <a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
       <code class="literal">
        MyISAM
       </code>
      </a>
      storage engine directly,
            you could get a substantial speed increase compared to using
            the SQL interface.
     </p>
     <p>
      Similarly, for databases using the
      <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
       <code class="literal">
        NDBCLUSTER
       </code>
      </a>
      storage engine, you
            may wish to investigate possible use of the NDB API (see
      <a class="ulink" href="/doc/ndbapi/en/" target="_top">
       MySQL NDB Cluster API Developer Guide
      </a>
      ).
     </p>
    </li>
    <li class="listitem">
     <p>
      Replication can provide a performance benefit for some
            operations. You can distribute client retrievals among
            replicas to split up the load. To avoid slowing down the
            source while making backups, you can make backups using a
            replica. See
      <a class="xref" href="replication.html" title="Chapter 19 Replication">
       Chapter 19,
       <i>
        Replication
       </i>
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
