我没有很多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)
但是行数与我从上次查询得到的数字不同。 你能解释一下为什么吗?这是一个错误还是一个预期的结果?