COUNT()和EXPLAIN行的计数正在变得不同

时间:2016-04-06 10:50:04

标签: mysql count explain

在Mysql中,我有一个表(employee_by_range)。我正在使用countexplain

获取行

当我尝试使用COUNT()获取行时,它会返回 15880256

mysql> select count(1) from test.employee_by_range;
+----------+
| count(1) |
+----------+
| 15880256 |
+----------+
1 row in set (4.80 sec)

当我尝试使用EXPLAIN获取行时,它返回 27912636

mysql> explain select emp_id from test.employee_by_range;
+----+-------------+-------------------+------+---------------+------+---------+------+----------+-------+
| id | select_type | table             | type | possible_keys | key  | key_len | ref  | rows     | Extra |
+----+-------------+-------------------+------+---------------+------+---------+------+----------+-------+
|  1 | SIMPLE      | employee_by_range | ALL  | NULL          | NULL | NULL    | NULL | 27912636 | NULL  |
+----+-------------+-------------------+------+---------------+------+---------+------+----------+-------+
1 row in set (0.00 sec)

为什么两行的计数不同?

0 个答案:

没有答案