I currently have just under a million locations in a mysql database all with longitude and latitude information.
I am trying to find the distance between one point a
Have a read of Geo Distance Search with MySQL, a solution based on implementation of Haversine Formula to MySQL. This is a complete solution description with theory, implementation and further performance optimization. Although the spatial optimization part didn't work correctly in my case.
I noticed two mistakes in this:
the use of abs
in the select statement on p8. I just omitted abs
and it worked.
the spatial search distance function on p27 does not convert to radians or multiply longitude by cos(latitude)
, unless his spatial data is loaded with this in consideration (cannot tell from context of article), but his example on p26 indicates that his spatial data POINT
is not loaded with radians or degrees.