how to get the nearest 100 points from one million data records quickly?

后端 未结 2 479
花落未央
花落未央 2021-01-20 16:42

given one point A, get the nearest 100 points from one million data records

  • database is MySql
  • one million records of latitude and lon
2条回答
  •  清歌不尽
    2021-01-20 17:09

    http://en.wikipedia.org/wiki/Geohash might be a quick way to speed up the average case, but worst case behaviour would still be bad. The article suggests that you index by geohash and, on a query, retrieve all points in a bounding box that amounts to a geohash prefix. If the bounding box is small and you find a match in it closer than any point outside the bounding box then you have succeeded quickly, but neither of these things might be true.

提交回复
热议问题