mysql> explain select * from T_Alarm_Information where recover_Date>'2013-06-03 09:57:00' and creat_Date<'2013-06-03 11:57:00';
+----+-------------+---------------------+------+------------------------+------+---------+------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------------------+------+------------------------+------+---------+------+----------+-------------+
| 1 | SIMPLE | T_Alarm_Information | ALL | i_t_alarm_info_rectime | NULL | NULL | NULL | 15647542 | Using where |
+----+-------------+---------------------+------+------------------------+------+---------+------+----------+-------------+
1 row in set (0.00 sec)但是我的索引是存在的啊
| t_alarm_information | 1 | i_t_alarm_info_rectime | 1 | CREAT_DATE | A | 205888 | NULL | NULL | | BTREE | |
| t_alarm_information | 1 | i_t_alarm_info_rectime | 2 | RECOVER_DATE | A | 340163 | NULL | NULL | YES | BTREE
为什么这里会用不到索引呢。表里有1500W数据,查询得到的结果是91条
+----+-------------+---------------------+------+------------------------+------+---------+------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------------------+------+------------------------+------+---------+------+----------+-------------+
| 1 | SIMPLE | T_Alarm_Information | ALL | i_t_alarm_info_rectime | NULL | NULL | NULL | 15647542 | Using where |
+----+-------------+---------------------+------+------------------------+------+---------+------+----------+-------------+
1 row in set (0.00 sec)但是我的索引是存在的啊
| t_alarm_information | 1 | i_t_alarm_info_rectime | 1 | CREAT_DATE | A | 205888 | NULL | NULL | | BTREE | |
| t_alarm_information | 1 | i_t_alarm_info_rectime | 2 | RECOVER_DATE | A | 340163 | NULL | NULL | YES | BTREE
为什么这里会用不到索引呢。表里有1500W数据,查询得到的结果是91条
解决方案 »
- 请问有人使用过maatkit工具么
- 关于一条SQL语句效率的问题
- 求助 mysql中 delete 嵌套select查询怎么写
- MYSQL 急!!#1016 - Can't open file: 'table_name.ibd' (errno: 1)
- postgresql 存储过程返回结果
- 字符串content='g1*5+g2';中有一个计算公式,我想把他的变量替换后计算出结果,我该如何写SQL语句呢?
- postgresql 类似 sleep的函数
- 关于MYSQL中ID重新排列问题
- 大家看看这句话错在哪?
- 求教:找不到 mysqlclient 文件如何处理?
- 如何在表里保存下载文件的路径
- Err 1064求解决
谢谢了,试了下果然OK了。谢谢ACMAIN_CHM版主