我对 DB 没有很多经验,但这件事有点令人困惑:首先我做了:
mysql> EXPLAIN SELECT COUNT(*) FROM tweets;
+----+-------------+--------+-------+---------------+---------+---------+------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+-------+---------------+---------+---------+------+----------+-------------+
| 1 | SIMPLE | tweets | index | NULL | user_id | 4 | NULL | 18683420 | Using index |
+----+-------------+--------+-------+---------------+---------+---------+------+----------+-------------+
1 row in set (0.03 sec)
比我试过这个:
mysql> SELECT COUNT(*) FROM tweets;
+----------+
| COUNT(*) |
+----------+
| 15254792 |
+----------+
1 row in set (9.60 sec)
但是行数与我从上次查询中获得的数字不同。你能解释一下为什么吗?这是一个错误还是预期的结果?