我想计算10,000点之间的距离矩阵。
例如:现在,store_store_diatance表大约有100000 * 100000行,查询效率非常差。那么如何改进,无论是mysql还是java代码。谢谢!
sql:
SELECT *
from store_store_distance
where origin_id in ('','','',...about 1000 points)
and target in ('','','',...about 1000 points)
但是,这很糟糕
答案 0 :(得分:0)
table point{
id
location
..whatever more
}
table distance{
id
point1 //FK to point id
point2 //FK to point id
distance
..whatever more
}
获取点之间的距离
SELECT distance FROM distance where (point1=x and point2=y) OR (point1=y and point2=x)
并且假设您没有复制距离,因为从X到Y的距离与从Y到X的距离相同。