So, in short,
- What should be the data type of latitude and longitude?
- What SQL command I should call to get the first 100 nearest restaurants for example?
Detail:
I have 100k biz record each with lattitude and longitude. I see that MySQL actually support a data type called point. Should I use that instead?
Does MySQL support KDTree storage system http://en.wikipedia.org/wiki/File:KDTree-animation.gif
Is it best to use point data type rather than regular float data type to store latitutude and longitude?
Eventually I want to find things like the first 100 restaurants closest to points 105,6 for example and my databases contains a lot of biz and points. Obviously computing the distance one by one for every records and for every points would be O(n) and hence sucks.
Notice that I am aware of a simpler solution described in How do Application Like Yelp Retrieve distance information from data base efficiently and will implement that my self too for a start. That's a good answer.
However, I think there is one creme of the crop answer that should outperform that right? In fact, storing location based on latitude and longitude and finding stuffs nearest to it is a very common problem I expect mysql to have a special design pattern for that. Does it have that?
Where can I learn more about it? Thanks.