[postgis-users] help optimize distance calculation
shlyon+postgis at gmail.com
Tue Jan 27 15:56:40 PST 2009
Hello all, I'm new to postgis and I'm hoping someone might help advise me!
I have a 4 million point grid of lat lon pairs that have an associated
the_geom. I have a 2,000 point feature set with an associated
the_geom. I'd like to find the nearest feature to each grid point. I
wrote the statement: select min(distance(f.the_geom,g.the_geom)) from
features f, grid g group by ao.gid to obtain my desired result set.
The only problem I had is that this query took 9949764 ms (approx 2.5
hours). Granted it's a large dataset, but I'd like to believe that
this calculation can be done more quickly. Any tips??
More information about the postgis-users