在Mysql中,我有一个表(employee_by_range)。我正在使用count
和explain
当我尝试使用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)
为什么两行的计数不同?