【发布时间】:2010-10-28 23:23:48
【问题描述】:
我在 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 之间的距离相同,但这仍然会导致表中有几百万行。
或者..有更好的方法吗?
【问题讨论】:
-
尝试静态查找表...生成的可执行文件大小应该很有趣:D ~ 2063! * 8 个字节(每个结果的浮点数)
标签: mysql google-maps performance geospatial