title: mysql spatial data speed
body: <p>I have a table with (among others) <code>x</code> and <code>y</code> fields of SMALLINT type and <code>pt</code> of POINT type, set to POINT(<code>x</code>,<code>y</code>);<br/>
  <code>x</code> and <code>y</code> have normal indecies and <code>pt</code> has a spatial index set.<br/></p>
  
  <p>Profiling typical query</p>
  
  <pre><code>select sql_no_cache
      count(0) from `table_name`
      where (x between -50 and 50)
      and (y between -50 and 50);
  -- vs
  set @g = GeomFromText('Polygon((-50 -50, 50 -50, 50 50, -50 50, -50 -50))');
  select sql_no_cache
      count(0) from `table_name`
      where MBRContains(@g, `pt`);
  </code></pre>
  
  <p>... shows that query via <code>x</code> and <code>y</code> is 1.5 times faster:<br/>
  3.45±0.10ms vs 4.61±0.14ms over 10 queries.<br/>
  <code>x</code> and <code>y</code> would always be INT and only rectangular (even square) areas would be queried. Yes, this is carved in stone ;-)</p>
  
  <p>The main question is:<br/>
  <strong>Have I missed something about indecies or is spatial data an overkill in such case?</strong><br/></p>
  
  <ul>
  <li>MySQL version is 5.1.37</li>
  <li>DB Engine type is MyISAM (default)</li>
  <li>Current table size is 5k rows, 10-30k planned in production.</li>
  </ul>
  
  <p>I have had some experience with MySQL, but never worked with spatial data types and spatial indecies.</p>