- 论坛徽章:
- 0
|
mysql 5.0.45 32位,A表500W条记录,B表1000W条记录
为啥两条一样的语句,就where里面的值不一样,调用的索引不一样啊。。。。。。
REF的0S就执行出来了,INDEX的需要18分钟。。。。。。
达人出来解释下啊
explain select count(*) from jiveMessageProp a,jiveMessage b where b.messageID=a.messageID and b.threadID='XEyklw7b';
+----+-------------+-------+------+---------------------------------------------------------------------+--------------------------+---------+--------------------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------------------------------------------------------------+--------------------------+---------+--------------------+--------+-------------+
| 1 | SIMPLE | b | ref | PRIMARY,jiveMessage_threadID_idx,jiveMessage_threadID_sg,idx_tid_cd | jiveMessage_threadID_idx | 20 | const | 1 | Using where |
| 1 | SIMPLE | a | ref | PRIMARY | PRIMARY | 20 | forum2.b.messageID | 104036 | Using index |
+----+-------------+-------+------+---------------------------------------------------------------------+--------------------------+---------+--------------------+--------+-------------+
2 rows in set (0.00 sec)
mysql> explain select count(*) from jiveMessageProp a,jiveMessage b where b.messageID=a.messageID and b.threadID='XEyklw7b1';
+----+-------------+-------+--------+---------------------------------------------------------------------+---------+---------+--------------------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+---------------------------------------------------------------------+---------+---------+--------------------+----------+-------------+
| 1 | SIMPLE | a | index | PRIMARY | PRIMARY | 222 | NULL | 10403609 | Using index |
| 1 | SIMPLE | b | eq_ref | PRIMARY,jiveMessage_threadID_idx,jiveMessage_threadID_sg,idx_tid_cd | PRIMARY | 20 | forum2.a.messageID | 1 | Using where |
|