【发布时间】:2017-03-13 10:39:38
【问题描述】:
我在我的 mysql 服务器中遇到了意外的结果。
行数多,查询时间少??
我有一个表和每个过滤器的总行数:
select count(*) from tcr where eid=648;
+----------+
| count(*) |
+----------+
| 11336 |
select count(*) from tcr where eid=997;
+----------+
| count(*) |
+----------+
| 1262307 |
但查询时间与每个过滤器的总行数相反:
select * from tcr where eid=648 order by start_time desc limit 0,10;
[data display]
10 rows in set (16.92 sec)
select * from tcr where eid=997 order by start_time desc limit 0,10;
[data display]
10 rows in set (0.21 sec)
“重置查询缓存”在每个查询 sql 之前执行。 表 tcr 的索引是
KEY `cridx_eid` (`eid`),
KEY `cridx_start_time` (`start_time`)
顺便说一句:附上解释结果:这很奇怪,但看起来更像我们采取的结果。(eid=997 的行数比 eid=648 少
explain select * from talk_call_record where eid=648 order by start_time desc limit 0,10;
+----+-------------+------------------+-------+---------------+------------------+---------+------+------+-------------+
|编号 |选择类型 |表|类型 |可能的键 |关键 | key_len |参考 |行 |额外 | +----+-------------+------------------+--------+--- ---------+------+---------+------+- -----+--------------+ | 1 |简单 |通话记录 |索引 | cridx_eid | cridx_start_time | 5 |空 | 3672 |使用位置 |
explain select * from talk_call_record where eid=997 order by start_time desc limit 0,10;
+----+-------------+------------------+-------+---------------+------------------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------------+-------+---------------+------------------+---------+------+------+-------------+
| 1 | SIMPLE | talk_call_record | index | cridx_eid | cridx_start_time | 5 | NULL | 32 | Using where |
【问题讨论】: