我使用以下SQL
在MySQL中对我的表做了一个非常简单的查询SELECT count(1) from allchangefiles;
这个花了将近半个小时才完成。以下是我的终端显示的内容:
mysql> select count(1) from allchangefiles;
+----------+
| count(1) |
+----------+
| 3047591 |
+----------+
1 row in set (23 min 13.22 sec)
我觉得这很荒谬,有什么建议吗?
mysql> explain select count(1) from allchangefiles;
+----+-------------+----------------+-------+---------------+---------+---------+------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------------+-------+---------------+---------+---------+------+---------+-------------+
| 1 | SIMPLE | allchangefiles | index | NULL | PRIMARY | 8 | NULL | 3429648 | Using index |
+----+-------------+----------------+-------+---------------+---------+---------+------+---------+-------------+
1 row in set (0.03 sec)