There are some ways to do big data paging on MySQL.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.