Effective ip->location query

我怕爱的太早我们不能终老 提交于 2019-12-05 08:24:40

Since you said other solutions are welcomed...

You might want to check out MaxMind. They have good country and city lookups by IP. You can install an Apache or PHP plugin to make it fast - don't even have to handle the database yourself.

To index your table:

ALTER TABLE `ip_group_city` ADD INDEX ( `ip_start` )

To get the top 10 region_codes:

SELECT igc.region_code
FROM ip_group_city igc
JOIN visits v ON igc.ip_start = v.ip
GROUP BY igc.region_code
ORDER BY COUNT(*) DESC
LIMIT 10
ALTER TABLE `ip_group_city` ADD INDEX ( `ip_start` )

thats all i'm saying. be sure to use btree and not hash :D

Farhad Malekpour

You might want to check this post:

Location from ip address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!