Adam Nelson writes:

> [...] POWER(SIN(((z.dblLon-o.dblLon)*0.017453293)/2),2))))) < $iRadius
> 
> This runs rather slowly over the 76 thousand zip codes in the US.
> 
> 2) Compute the max/min latitude/longitude and then query on that range
> (proximity becomes a square, but that's not a big deal)
> 
> Does anyone have any recommendations (or a better query that doesn't
> have to use a function for every row).

Since you have to within a square to be within the circle, you
could restrict to the bounding box, and make sure that MySQL only
runs that complicated expression for points within it. You'd need
to index at least one of latitude and longitude.

BTW, I don't want to spend time loooking at it, but... does your
expression really work near the poles?

//C - three-dimensional

-- 
 Carl Troein - Círdan / Istari-PixelMagic - UIN 16353280
 [EMAIL PROTECTED] | http://pixelmagic.dyndns.org/~cirdan/
 Amiga user since '89, and damned proud of it too.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to