title: Database: Best performance way to query geo location data?
body: <p>I have a MySQL database. I store homes in the database and perform literally just 1 query against the database, <strong><em>but I need this query to be performed super fast</em></strong>, and that's to return all homes within a square box geo latitude &amp; longitude.</p>
  
  <pre><code>SELECT * FROM homes 
  WHERE geolat BETWEEN ??? AND ???
  AND geolng BETWEEN ??? AND ???
  </code></pre>
  
  <p>How is the best way for me to store my geo data so that I can perform this query of displaying all home within the geolocation box the quickest?</p>
  
  <p>Basically:</p>
  
  <ul>
  <li>Am I using the best SQL statement to perform this query the quickest?</li>
  <li>Does any other method exist, maybe not even using a database, for me to query the fastest way a result of homes within a boxed geolocation bounds?</li>
  </ul>
  
  <p>In case it helps, I've include my database table schema below:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `homes` (
    `home_id` int(10) unsigned NOT NULL auto_increment,
    `address` varchar(128) collate utf8_unicode_ci NOT NULL,
    `city` varchar(64) collate utf8_unicode_ci NOT NULL,
    `state` varchar(2) collate utf8_unicode_ci NOT NULL,
    `zip` mediumint(8) unsigned NOT NULL,
    `price` mediumint(8) unsigned NOT NULL,
    `sqft` smallint(5) unsigned NOT NULL,
    `year_built` smallint(5) unsigned NOT NULL,
    `geolat` decimal(10,6) default NULL,
    `geolng` decimal(10,6) default NULL,
    PRIMARY KEY  (`home_id`),
    KEY `geolat` (`geolat`),
    KEY `geolng` (`geolng`),
  ) ENGINE=InnoDB  ;
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I understand spatial will factor in the curvature of the earth but I'm most interested in returning geo data the FASTEST. Unless these spatial database packages somehow return data faster, please don't recommend spatial extensions. Thanks</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Please note, no one below has truly answered the question. I'm really looking forward to any assistance I might receive. Thanks in advance.</p>