<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="optimizing-spatial-analysis">
      </a>
      13.4.9 Optimizing Spatial Analysis
     </h3>
    </div>
   </div>
  </div>
  <p>
   For
   <a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
    <code class="literal">
     MyISAM
    </code>
   </a>
   and
   <code class="literal">
    InnoDB
   </code>
   tables, search operations in columns
        containing spatial data can be optimized using
   <code class="literal">
    SPATIAL
   </code>
   indexes. The most typical operations
        are:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Point queries that search for all objects that contain a
            given point
     </p>
    </li>
    <li class="listitem">
     <p>
      Region queries that search for all objects that overlap a
            given region
     </p>
    </li>
   </ul>
  </div>
  <p>
   MySQL uses
   <span class="bold">
    <strong>
     R-Trees with quadratic
        splitting
    </strong>
   </span>
   for
   <code class="literal">
    SPATIAL
   </code>
   indexes on
        spatial columns. A
   <code class="literal">
    SPATIAL
   </code>
   index is built
        using the minimum bounding rectangle (MBR) of a geometry. For
        most geometries, the MBR is a minimum rectangle that surrounds
        the geometries. For a horizontal or a vertical linestring, the
        MBR is a rectangle degenerated into the linestring. For a point,
        the MBR is a rectangle degenerated into the point.
  </p>
  <p>
   It is also possible to create normal indexes on spatial columns.
        In a non-
   <code class="literal">
    SPATIAL
   </code>
   index, you must declare a
        prefix for any spatial column except for
   <code class="literal">
    POINT
   </code>
   columns.
  </p>
  <p>
   <code class="literal">
    MyISAM
   </code>
   and
   <code class="literal">
    InnoDB
   </code>
   support
        both
   <code class="literal">
    SPATIAL
   </code>
   and
        non-
   <code class="literal">
    SPATIAL
   </code>
   indexes. Other storage engines
        support non-
   <code class="literal">
    SPATIAL
   </code>
   indexes, as described in
   <a class="xref" href="create-index.html" title="15.1.15 CREATE INDEX Statement">
    Section 15.1.15, “CREATE INDEX Statement”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
