Home >Backend Development >PHP Tutorial >关于高效查询IP地址段的问题,谢谢

关于高效查询IP地址段的问题,谢谢

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:26:181035browse

MYSQL数据库:

用户表(user),大概2000条数据,有一个IP字段(已经转换成整数了);
IP地址表(ip),44万条数据,一个IP起始字段和IP结束字段(已经转换成整数了),和IP物理地址字段;

现在需要通过SQL脚本,找出《用户表》每条记录IP对应的物理地址,用如下SQL脚本查询速度实在太慢,等了好久都没有出结果

select user.*, ip.addressfrom user left join ipon user.ip between ip.ipstart and ip.ipend



求教更有效率的查询方法,谢谢


回复讨论(解决方案)

按 EXPLAIN 的信息调整

按 EXPLAIN 的信息调整



什么意思,没看懂,谢谢

执行  EXPLAIN 你的查询指令
mysql 就会告诉你可能是哪里可以优化


按 EXPLAIN 的信息调整



什么意思,没看懂,谢谢
版主的意思是你explain/desc 分析sql语句

太复杂了,太复杂了,

1+1=2 很简单,但只会 1+1=2 是没有饭吃的
1+1=1 很复杂,研究 1+1=1 的人永远都有饭吃

版主的话太深奥了。。。

果然有见地

版主教教我吧,怎么优化,我向你学习,

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php http post 如何改写?Next article:批量生成url