Re: Zip Code Proximity search
Gregor Melhorn wrote:
> The problem is, I loose performance, since I need
> the database to look at each zip in the database
> (about 20 000 in Germany) for each request,
> calculate the distance and afterwards do a sort on
> it, since I want the zips sorted by distance.
>
> This is by no means a solution for a
> high-performance application, but thanks anyway
> for your help...
Wait.. I'm not sure I understand - you don't need the database to do any sorting.
With one quick calculation in your application you determine a high and low latitude
and longitude. You then query the database for all zips in between those which should
be a blazingly fast index lookup.
Then once you have this small subset of zips in your application you can run the
more compute intensive distance calculations in your application on this small set
of zip codes.
So.. a one step calculation in your app, then you do a very quick index lookup
in the database and finally do the required more intensive calculations back in your
application - but over a *very* reduced set of zip codes that are almost all in your
required radius.
felix