查询很慢啊 本帖最后由 vickyli0307 于 2009-11-30 14:24:52 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用explain跟踪分析下吧看看索引是否走得跟你想要的一样没有 +----+-------------+-------+------+---------------+------+---------+-------------------+--------+---------------------------------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |+----+-------------+-------+------+---------------+------+---------+-------------------+--------+---------------------------------+| 1 | SIMPLE | a | ALL | PRIMARY | NULL | NULL | NULL | 100230 | Using temporary; Using filesort || 1 | SIMPLE | b | ref | dat,Index_3 | dat | 42 | inventory.a.jobNo | 1 | Using where |+----+-------------+-------+------+---------------+------+---------+-------------------+--------+---------------------------------+ 在jobsheet中索引有:primary(jid),dat(jobno),index_3(createdate)在jobs中的索引有:primary(jobno) SELECT * FROM jobsheet where createDate>='2008-11-30' and createDate <'2009-12-01'这个查询也要5s.共查到10W条记录, 在createdate上建有索引呢用explain分析+----+-------------+----------+------+---------------+------+---------+------+--------+-------------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |+----+-------------+----------+------+---------------+------+---------+------+--------+-------------+| 1 | SIMPLE | jobsheet | ALL | Index_3 | NULL | NULL | NULL | 100224 | Using where |+----+-------------+----------+------+---------------+------+---------+------+--------+-------------+ 当您的问题得到解答后请及时结贴.http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html 求助!!!! mysql命令行表格歪曲显示怎么办? JAVA多线程访问MySQL执行insert,插入数据数量不对,精分了! 翻译 Twin Project mysql---附加下载的数据库,谢谢! MySQL简单问题.怎么增加用户? 这个Sql语句怎么写? 在bin目录下敲入mysql没有任何反应 sql统计三位学生缺考的课程 MYSQL建表的一个问题..想知道了解了MYSQL的一些基础后进阶知识怎么学习 mysql并发控制问题 oder by 后面能不能接select查询的啊
看看索引是否走得跟你想要的一样没有
-------+--------+---------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref
| rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------------
-------+--------+---------------------------------+
| 1 | SIMPLE | a | ALL | PRIMARY | NULL | NULL | NULL
| 100230 | Using temporary; Using filesort |
| 1 | SIMPLE | b | ref | dat,Index_3 | dat | 42 | inventory.a
.jobNo | 1 | Using where |
+----+-------------+-------+------+---------------+------+---------+------------
-------+--------+---------------------------------+
在jobs中的索引有:primary(jobno)
这个查询也要5s.共查到10W条记录, 在createdate上建有索引呢
用explain分析
+----+-------------+----------+------+---------------+------+---------+------+--
------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+------+---------------+------+---------+------+--
------+-------------+
| 1 | SIMPLE | jobsheet | ALL | Index_3 | NULL | NULL | NULL | 100224 | Using where |
+----+-------------+----------+------+---------------+------+---------+------+--
------+-------------+
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html