This is an old revision of the document!


Geographic Searches - Indexing

Optimizing Geographic Searches

Geographic searches are specified using a $distance function. As long as there is a multi-column Omnidex index containing the latitude and longitude, the $distance function will be automatically optimized.

Examples

The following are examples of several types of geographic searches that can be optimized using the $distance function.

Distance between two sets of coordinates

select      $distance(40.0, -105.0, 41.0, -106.0) 
  from 	    $omnidex 

Distance between two sets of coordinates using columns

select      $distance(40.0, -105.0, latitude, longitude), 
            latitude, longitude,
  from      geo
 where      $distance(40.0, -105.0, latitude, longitude) < 10

Distance between two sets of coordinates using a subquery

select      latitude, longitude,
  from      geo
  where     $distance((select      latitude, longitude 
                         from      zipcodes 
                         where     zip = ‘80301’),
                      latitude, longitude) < 10

Distance between multiple sets of coordinates using a subquery

select      latitude, longitude,
  from      geo
 where      $distance((select      latitude, longitude 
                         from      zipcodes 
                        where      region = 'MT'),
                      latitude, longitude) < 10
 
Back to top
admin/optimization/geo/optimization.1280329611.txt.gz · Last modified: 2012/10/26 14:52 (external edit)