MySQL select coordinates within range

后端 未结 5 1684
有刺的猬
有刺的猬 2020-11-28 12:38

I\'ve in my database 100 000 addresses (that is records).

Each one of them has its own coordinates (latitude and longitude).

Now, given the geo location of

5条回答
  •  盖世英雄少女心
    2020-11-28 13:11

    I would think MySQL's geo spatial extensions would solve this for you: http://dev.mysql.com/doc/refman/5.7/en/gis-introduction.html

    Otherwise you could index on lattitude then query WHERE lattitude > userLat-5miles and lattitude < userLat+5miles. That would massively reduce the number of possible rows to process in the application layer.

提交回复
热议问题