Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-06 19:43:07
Original
925 people have browsed it

关于高效查询IP地址段的问题,谢谢 MYSQL数据库: 用户表(user),大概2000条数据,有一个IP字段(已经转换成整数了); IP地址表(ip),44万条数据,一个IP起始字段和IP结束字段(已经转换成整数了),和IP物理地址字段; 现在需要通过SQL脚本,找出《用户

关于高效查询IP地址段的问题,谢谢
MYSQL数据库:

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

现在需要通过SQL脚本,找出《用户表》每条记录IP对应的物理地址,用如下SQL脚本查询【本文来自鸿网互联 (http://www.68idc.cn)】速度实在太慢,等了好久都没有出结果

<br />
select user.*, ip.address<br />
from user left join ip<br />
on user.ip between ip.ipstart and ip.ipend<br />
Copy after login



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

------解决思路----------------------
执行 EXPLAIN 你的查询指令
mysql 就会告诉你可能是哪里可以优化
------解决思路----------------------
引用:
Quote: 引用:

按 EXPLAIN 的信息调整


什么意思,没看懂,谢谢

版主的意思是你explain/desc 分析sql语句
Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!