High ratio of rows returned to index
In MySQL, the number of rows returned by the query exceeds 20% of the total number of rows, and the execution plan will not take the index. Let's look at an example to query information with an id greater than 1.
Click (here) to collapse or open
Mysql > explain select * from test06 where id > 1
+-- +
| | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+-- +
| | 1 | SIMPLE | test06 | ALL | idx_test03_id | NULL | NULL | NULL | 2009559 | Using where |
When the proportion of returned rows is high, the optimizer thinks that full table scanning saves time. Indexes are not used.