title: More results - faster query (search by latitude and longitude in mysql)
body: <p>I use MySQL database with innoDB storage engine.
  I was trying to speed up the query for searching places by latitude and longitude and I found out that a search with smaller radius, less results performs slower than the one with more results. (latitude and longitude is the same, column ID is the primary key). </p>
  
  <p>0.0011 sec, 15404 results</p>
  
  <pre><code>SELECT ID, 69.0 * DEGREES(ACOS(COS(RADIANS(51.5099983215332)) *
      COS(RADIANS(Lat)) * COS(RADIANS(-0.05000000074505806) - RADIANS(Lng)) +
      SIN(RADIANS(51.5099983215332)) * SIN(RADIANS(Lat)))) AS distance
  FROM Table 
  WHERE (Lat BETWEEN 51.5099983215332 - (18 / 69.0)
                 AND 51.5099983215332 + (18 / 69.0)
     AND Lng BETWEEN -0.05000000074505806 - (18 / (69.0 * COS(RADIANS(51.5099983215332))))
                 AND -0.05000000074505806 + (18 / (69.0 * COS(RADIANS(51.5099983215332)))) ) 
  HAVING distance &lt;= 18 
  </code></pre>
  
  <p>0.0319 sec, 105 results</p>
  
  <pre><code>SELECT ID, 69.0 * DEGREES(ACOS(COS(RADIANS(51.5099983215332)) *
      COS(RADIANS(Lat)) * COS(RADIANS(-0.05000000074505806) - RADIANS(Lng)) +
      SIN(RADIANS(51.5099983215332)) * SIN(RADIANS(Lat)))) AS distance
  FROM Table
  WHERE (Lat BETWEEN 51.5099983215332 - (0.5 / 69.0)
                 AND 51.5099983215332 + (0.5 / 69.0)
     AND Lng BETWEEN -0.05000000074505806 - (0.5 / (69.0 * COS(RADIANS(51.5099983215332))))
                 AND -0.05000000074505806 + (0.5 / (69.0 * COS(RADIANS(51.5099983215332)))) ) 
  HAVING distance &lt;= 0.5 
  </code></pre>
  
  <p>Is that OK?</p>