MySQL Massive data paging optimization code

Source: Internet
Author: User
Tags mysql tutorial

MySQL tutorial massive data paging optimization code
Page represents page number
PageSize represents the number of displays per page
Conditon represents some conditions view sourceprint?1 select * FROM table where Conditon order by ID limit (page-1) *pagesize,pagesize;
Such pagination in the early days did not appear any problems, but when the table and the data reached 100W, slowly appeared problems, search hundreds of pages, often to use more than 2 seconds to search the Internet, online changes can refer to, the temporary solution to the problem
SELECT sql_no_cache *from table where id>= (selectsql_no_cache ID from table where Conditon order by ID DESC LIMIT 12638 0,1) limit 20;


Cache. Such a change of 0.0 seconds can be done, in fact, this change is mainly because of the use of the index ID.

Audit=1 and Share=1

The index design of my table is that the primary key is Id,audit and share is a federated index

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.