此表有几百万行,子标识1有50,000。我想找到子ID 1的1000条最新行,并且说明显示搜索到99000行。为什么我没有索引,为什么没有1000?
CREATE TABLE foo(
id int unsigned primary key auto_increment,
subid int,
json text,
INDEX(subid,id))
explain select * from foo where subid=1 order by id DESC limit 1000;
+----+-------------+-----------+------------+------+---------------+-------+---------+-------+-------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-----------+------------+------+---------------+-------+---------+-------+-------+----------+-------------+
| 1 | SIMPLE | foo | NULL | ref | subid | subid | 5 | const | 99748 | 100.00 | Using where |
+----+-------------+-----------+------------+------+---------------+-------+---------+-------+-------+----------+-------------+