SELECT * from user limit 0, 10; The most common method is not a problem when the amount of data is small.
When the amount of data is greater than 100W, select * from user limit 1000000,10; This time the database
To sweep the previous 100W records, and then to fetch 10, so when the volume of data is getting larger, the speed will be more and more slow.
Solution:
1, from the business, the limit can only take the first 70 pages or the first 30 pages of data. such as Baidu, Google search.
2. Use SELECT * from user where ID > 1000000 limit 10;
The index is used at this time, so it is faster and less difficult to use this method to ensure the integrity of the data, that is, the previous data can not
has been removed.
If you want to delete the previous data, and you want to use this method, you can only tombstone the data, for example, add a Is_del field
3. Select id from user limit 1000000, 10;
The ID is queried first, the index is used, and then the corresponding data is obtained from the ID.
Select Id,name from user inner join can be used (select ID from the user limit 1000000,;) as TEM on TM P.id = user.id;
There are some ways to do big data paging on MySQL.