Database Reference
In-Depth Information
41.396679), 4326), 3734) AS the_geom)
searchpoint
ORDER BY ST_Distance(searchpoint.the_geom,
addr.the_geom)
LIMIT 10;
Thisisafineapproachforsmallerdatasets.Thisisalogical,simple,fastapproach
forrelativelysmallnumbersofrecords.Thisapproachscalesverypoorly,however,
getting exponentially slower with the addition of records, and with 500,000 points,
this would take a very long time.
AnalternativeistoonlycomparemypointtotheonesIknowareclosebysettinga
searchdistance.So,forexample,inthefollowingdiagram,wehaveastarthatrep-
resentsmycurrentlocation,andIwanttoknowthe10closestaddresses.Thegrid
inthediagramisa100footgrid,soIcansearchforthepointswithin200feet,then
measurethedistancetoeachofthesepoints,andreturntheclosest10pointstomy
search location.