MySQL select coordinates within range

后端 未结 5 1683
有刺的猬
有刺的猬 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 12:51

    Mr UpsideDown, I've been looking for an answer to this question for weeks, and there is a very good solution that surprisingly I didn't find anywhere else. You would have to create a stored procedure, limit the proximity with Java before you apply it to the MySQL query, and the query will return the results in a matter of miliseconds, I'm using this in a table where there are over 900K users and you can search by proximity in under 100ms with this technique (it's explained with PHP, but the MySQL trick that you need is still there):

    http://cssshowcase.co.uk/mysql-get-distance-by-latitude-and-longitude-coordinates/

    No other solution worked as good and as fast as the above, other solutions on the web made the query take 15-20 seconds, which obviously isn't good.

提交回复
热议问题