使用explain分析你的sql



mysql> explain select * from forum_thread where tid != 1000;
+----+-------------+--------------+------+---------------+------+---------+------+--------+-------------+
| id | select_type | table        | type | possible_keys | key  | key_len | ref  | rows   | Extra       |
+----+-------------+--------------+------+---------------+------+---------+------+--------+-------------+
|  1 | SIMPLE      | forum_thread | ALL  | PRIMARY       | NULL | NULL    | NULL | 750660 | Using where |
+----+-------------+--------------+------+---------------+------+---------+------+--------+-------------+
1 row in set (0.03 sec)

mysql> explain select * from forum_thread where tid != 1000 and tid in (123,324,23435,564654,34543,234,12,45,6,7);
+----+-------------+--------------+-------+---------------+---------+---------+------+------+-------------+
| id | select_type | table        | type  | possible_keys | key     | key_len | ref  | rows | Extra       |
+----+-------------+--------------+-------+---------------+---------+---------+------+------+-------------+
|  1 | SIMPLE      | forum_thread | range | PRIMARY       | PRIMARY | 3       | NULL |   10 | Using where |
+----+-------------+--------------+-------+---------------+---------+---------+------+------+-------------+
1 row in set (0.02 sec)



你可能感兴趣的:(thread,sql,mysql)