MySQL在一个简单的查询上非常慢

时间:2013-07-28 19:34:50

标签: mysql

我使用以下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)

0 个答案:

没有答案