When a data table contains a large amount of data, you only need to check the values of some of the fields, instead of all the data, you only need to check a few rows. At this time, you can use limit
For example:
1. select * from tags limit 4; it is to take 4 rows of data and see what the values of id or other required fields are.
The query result is: id = 102 or...
2. explain select * from tags where id = 102; check whether the id or other fields in the table are valid for the index.
+ ---- + ------------- + ---------- + ------ + --------------- + ------ + --------- + ------- +
| Id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+ ---- + ------------- + ---------- + ------ + --------------- + ------ + --------- + ------- +
| 102 | SIMPLE | tags | ALL | NULL | 6226057 |
+ ---- + ------------- + ---------- + ------ + --------------- + ------ + --------- + ------- +
It can be seen that the id index is not used here [the index created for id is generally PRIMARY]
Author hllnihao