mysql> explain SELECT * FROM uchome_feed force index(uid) WHERE uid IN ('0',16,109,164,182,238,268,388,403,475);
+----+-------------+-------------+------+---------------+------+---------+------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+------+---------------+------+---------+------+--------+-------------+
| 1 | SIMPLE | uchome_feed | ALL | uid | NULL | NULL | NULL | 449779 | Using where |
+----+-------------+-------------+------+---------------+------+---------+------+--------+-------------+强制使用索引居然也没用,mysql in操作难道不走索引??
该如何优化??
+----+-------------+-------------+------+---------------+------+---------+------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+------+---------------+------+---------+------+--------+-------------+
| 1 | SIMPLE | uchome_feed | ALL | uid | NULL | NULL | NULL | 449779 | Using where |
+----+-------------+-------------+------+---------------+------+---------+------+--------+-------------+强制使用索引居然也没用,mysql in操作难道不走索引??
该如何优化??
show index from uchome_feed;看一下。
+-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| uchome_feed | 0 | PRIMARY | 1 | feedid | A | 449779 | NULL | NULL | | BTREE | |
| uchome_feed | 1 | uid | 1 | uid | A | 449779 | NULL | NULL | | BTREE | |
| uchome_feed | 1 | uid | 2 | dateline | A | 449779 | NULL | NULL | | BTREE | |
| uchome_feed | 1 | dateline | 1 | dateline | A | 24987 | NULL | NULL | | BTREE | |
| uchome_feed | 1 | hot | 1 | hot | A | 37 | NULL | NULL | | BTREE | |
| uchome_feed | 1 | id | 1 | id | A | 1578 | NULL | NULL | | BTREE | |
| uchome_feed | 1 | id | 2 | idtype | A | 3627 | NULL | NULL | | BTREE | |
| uchome_feed | 1 | icon | 1 | icon | A | 73 | 20 | NULL | | BTREE | |
| uchome_feed | 1 | uids | 1 | uid | A | 449779 | NULL | NULL | | BTREE | |
+-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
9 rows in set (0.01 sec)