我在 mysql 表中存储了 2063 个位置。在我的一个过程中,我需要根据它们与给定原点的距离来排除某些结果。问题是,我需要一次过滤几百个甚至几千个结果。
那么进行距离数学的最佳方法是什么。我应该在运行时做吗
1. Find all points connecting to my point of origin
2. loops through the connecting points
3. calculate the distance between the point of origin and the connecting point
4. exclude the connecting point if the distance if too great
或者我应该创建一个查找表,其中包含已经计算出的每个点之间的距离。我可以避免重复行,因为 p1 和 p2 之间的距离与 p2 和 p1 之间的距离相同,但这仍然会导致表中出现几百万行。
或者..有更好的方法吗?