56,679
社区成员
发帖
与我相关
我的任务
分享
mysql> analyze local table tw_wall_records;
+----------------------+---------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+----------------------+---------+----------+----------+
| test.tw_wall_records | analyze | status | OK |
+----------------------+---------+----------+----------+
1 row in set (0.32 sec)
mysql> explain select count(*) from tw_wall_records where module='10086';
+----+-------------+-----------------+-------+---------------+------------+---------+------+--------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------------+-------+---------------+------------+---------+------+--------+--------------------------+
| 1 | SIMPLE | tw_wall_records | index | NULL | idx_title1 | 99 | NULL | 974289 | Using where; Using index |
+----+-------------+-----------------+-------+---------------+------------+---------+------+--------+--------------------------+
1 row in set (0.00 sec)
mysql> explain select * from tw_wall_records where module='10086';
+----+-------------+-----------------+------+---------------+------+---------+------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------------+------+---------------+------+---------+------+--------+-------------+
| 1 | SIMPLE | tw_wall_records | ALL | NULL | NULL | NULL | NULL | 974289 | Using where |
+----+-------------+-----------------+------+---------------+------+---------+------+--------+-------------+
1 row in set (0.00 sec)
mysql> show index from tw_wall_records;
+-----------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-----------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| tw_wall_records | 0 | PRIMARY | 1 | id | A | 1085925 | NULL | NULL | | BTREE | |
| tw_wall_records | 1 | idx_title1 | 1 | user_name | A | 57153 | NULL | NULL | | BTREE | |
| tw_wall_records | 1 | idx_title1 | 2 | module | A | 77566 | NULL | NULL | | BTREE | |
| tw_wall_records | 1 | idx_all | 1 | user_id | A | 20 | NULL | NULL | | BTREE | |
| tw_wall_records | 1 | idx_all | 2 | module | A | 20 | NULL | NULL | | BTREE | |
| tw_wall_records | 1 | idx_all | 3 | type | A | 20 | NULL | NULL | | BTREE | |
| tw_wall_records | 1 | idx_all | 4 | ns | A | 20 | NULL | NULL | YES | BTREE | |
| tw_wall_records | 1 | idx_all | 5 | title | A | 1085925 | NULL | NULL | | BTREE | |
| tw_wall_records | 1 | idx_all | 6 | id | A | 1085925 | NULL | NULL | | BTREE | |
| tw_wall_records | 1 | idx_type | 1 | type | A | 20 | 11 | NULL | | BTREE | |
| tw_wall_records | 1 | idx_type_1 | 1 | type | A | 1057 | 11 | NULL | | BTREE | |
| tw_wall_records | 1 | idx_type_1 | 2 | user_name | A | 54296 | 19 | NULL | | BTREE | |
+-----------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
12 rows in set (0.35 sec)