title: Database/SQL: How to store longitude/latitude data?
body: <p>Performance question ...</p>
  
  <p>I have a database of houses that have geolocation data (longitude &amp; latitude).</p>
  
  <p>What I want to do is find the best way to store the locational data in my MySQL (v5.0.24a) using InnoDB database-engine so that I can perform a lot of queries where I'm returning all the home records that are between x1 and x2 <code>latitude</code> and y1 and y2 <code>longitude</code>.</p>
  
  <p>Right now, my database schema is</p>
  
  <pre><code>---------------------
  Homes   
  ---------------------
  geolat - Float (10,6)
  geolng - Float (10,6)
  ---------------------
  </code></pre>
  
  <p>And my query is:</p>
  
  <pre><code>SELECT ... 
  WHERE geolat BETWEEN x1 AND x2
  AND geolng BETWEEN y1 AND y2
  </code></pre>
  
  <ul>
  <li>Is what I described above the best way to store the
  latitude and longitude data in MySQL using Float (10,6) and separating out the longitude/latitude? If not, what is? There exist Float, Decimal and even Spatial as a data type.</li>
  <li>Is this the best way to perform the
  SQL from a performance standpoint? If not, what is?</li>
  <li>Does using a different MySQL
  database-engine make sense?</li>
  </ul>
  
  <p><strong>UPDATE: Still Unanswered</strong></p>
  
  <p>I have 3 different answers below. One person say to use <code>Float</code>. One person says to use <code>INT</code>. One person says to use <code>Spatial</code>.</p>
  
  <p>So I used MySQL "EXPLAIN" statement to measure the SQL execution speed. It appears that absolutely no difference in SQL execution (result set fetching) exist if using <code>INT</code> or <code>FLOAT</code> for the longitude and latitude data type..</p>
  
  <p>It also appears that using the "<code>BETWEEN</code>" statement is SIGNIFICANTLY faster than using the "<code>&gt;</code>" or "<code>&lt;</code>" SQL statements. It's nearly 3x faster to use "<code>BETWEEN</code>" than to use the "<code>&gt;</code>" and "<code>&lt;</code>" statement.</p>
  
  <p>With that being said, I still am unceratin on what the performance impact would be if using Spatial since it's unclear to me if it's supported with my version of MySQL running (v5.0.24) ... as well as how I enable it if supported.</p>
  
  <p><strong>Any help would be greatly appreacited</strong></p>