搜索重复的大型地理空间数据库

发布于 2024-12-18 09:29:59 字数 481 浏览 5 评论 0原文

我正在 MySQL 中使用 maxmind geocities 表(参见此处) (视窗)。

该表有超过 270 万行(非常大)。

我正在尝试按照经度和纬度查找城市重复项(以便找到每个城市的不同拼写,例如 pekin (fr)、beijing...)。

即使我使用左外连接、子请求或复杂的 where 子句,但响应时间太长(永远不会结束)。

这是我的最后一次尝试:

select * 
from cities c1, cities c2 
where c2.longitude=c1.longitude 
and c2.latitude=c1.latitude 
and c2.cities!=c1.cities

有人有想法吗?

I'm working with maxmind geocities table (see here), in MySQL (Windows).

This table has more than 2.7 millions lines (so pretty large).

I'm trying to find cities duplicates (in order to find the different spelling for each cities like pekin (fr), beijing...) following their longitude and latitude.

Even if I use left outer join, a subrequest or a complex where clause, but the response time is too long (it never ends).

Here is my last try:

select * 
from cities c1, cities c2 
where c2.longitude=c1.longitude 
and c2.latitude=c1.latitude 
and c2.cities!=c1.cities

Does anybody has an idea.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓦然回首 2024-12-25 09:29:59

您可以通过不选择 * (我认为 cities 就足够了)并在 cities(longitude,latitude) 上添加索引来加快查询速度,甚至在城市(经度、纬度、城市) 上。你也可以尝试

SELECT longitude,latitude, COUNT(DISTINCT c.cities) as num_dup
FROM cities c
GROUP BY longitude,latitude
HAVING num_dup > 1

You can speed up your query by not selecting * (I think cities is enough) and adding index on cities(longtitude,latitude) or even on cities(longtitude,latitude, cities) . You can also try

SELECT longitude,latitude, COUNT(DISTINCT c.cities) as num_dup
FROM cities c
GROUP BY longitude,latitude
HAVING num_dup > 1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文