我在我的mysql服務器中遇到了一個意外的結果。mysql選擇的時間與實際行不一樣
行數越多,查詢時間越少?
我有一個表,併爲每個過濾器總行:
select count(*) from tcr where eid=648;
+----------+
| count(*) |
+----------+
| 11336 |
select count(*) from tcr where eid=997;
+----------+
| count(*) |
+----------+
| 1262307 |
但查詢時間oppisite總線每個過濾器:
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`)
BTW:附上解釋的結果:這是很奇怪,但它看起來更像是我們採取的reuslt(的EID = 997具有比EID = 648
線少explain select * from talk_call_record where eid=648 order by start_time desc limit 0,10;
+----+-------------+------------------+-------+---------------+------------------+---------+------+------+-------------+
| ID | SELECT_TYPE |表|類型| possible_keys |關鍵| key_len |裁判|行|額外| + ---- + ------------- + --- --------------- + ------- + -------- + ---------- -------- + --------- + ------ + ------ + ------------- + | 1 | SIMPLE | talk_call_record | index | cridx_eid | cridx_start_time | 5 | NULL | 3672 | Usi ng where |
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 |