mysql查询慢

java123object 2013-01-08 09:48:58
我的表有400万数据,以下的查询,达到了28秒,其中Sending data为27秒以上,不知是啥原因哦!
districtlist已建索引,以下是查询语句:
select `phone`,`seat` from `numbers` where `districtlist`=3 order by `porder` asc limit 101182
...全文
246 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
java123object 2013-01-09
  • 打赏
  • 举报
回复
引用 11 楼 zuoxingyu2012 的回复:
show create table 然后把结果1里的值贴出来。是想看看你的表索引。
表索引在最后6楼最后一张图片!
珠海-天堂 2013-01-09
  • 打赏
  • 举报
回复
show create table 然后把结果1里的值贴出来。是想看看你的表索引。
泥瓦匠1024 2013-01-09
  • 打赏
  • 举报
回复
什么需求需要查101182条数据?
java123object 2013-01-09
  • 打赏
  • 举报
回复
引用 8 楼 zuoxingyu2012 的回复:
1:整理下业务,你真的需要101182条记录么?
select `phone`,`seat` from `numbers` where `districtlist`=3 order by `porder` asc limit 101182
2:查询计划已经使用了索引,但是需要扫描的行还是很多,
select count(distinct(districtlist))……


1、2、是的,我需要按一定条件查询出所需的行数,这并不是在页面显示,而是将这些数据拿去与其它表匹对;
3、


表结构:


使用navicat查询都觉得有点慢,我使用cakephp框架就更慢了查询,参考一下我的另一个贴子:
http://bbs.csdn.net/topics/390337557
珠海-天堂 2013-01-09
  • 打赏
  • 举报
回复
1:整理下业务,你真的需要101182条记录么? select `phone`,`seat` from `numbers` where `districtlist`=3 order by `porder` asc limit 101182 2:查询计划已经使用了索引,但是需要扫描的行还是很多, select count(distinct(districtlist))/count(*) from `numbers`; 看看这个字段的唯一性怎么样 3:show create table `numbers`; 贴出来看看。
java123object 2013-01-08
  • 打赏
  • 举报
回复
引用 5 楼 ACMAIN_CHM 的回复:
贴出你的 show index from ..;
explain select ...
以供分析。




java123object 2013-01-08
  • 打赏
  • 举报
回复
引用 5 楼 ACMAIN_CHM 的回复:
贴出你的 show index from ..;
explain select ...
以供分析。




ACMAIN_CHM 2013-01-08
  • 打赏
  • 举报
回复
贴出你的 show index from ..; explain select ... 以供分析。
java123object 2013-01-08
  • 打赏
  • 举报
回复
引用 3 楼 ACMAIN_CHM 的回复:
create index xx on numbers (districtlist,porder)
建了联合索引,还是要24秒!
ACMAIN_CHM 2013-01-08
  • 打赏
  • 举报
回复
create index xx on numbers (districtlist,porder)
java123object 2013-01-08
  • 打赏
  • 举报
回复
引用 1 楼 rucypli 的回复:
districtlist和porder加索引 alter table numbers add index(districtlist,porder)
按你的方法建立后,还是不行,要24秒
rucypli 2013-01-08
  • 打赏
  • 举报
回复
districtlist和porder加索引 alter table numbers add index(districtlist,porder)

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧