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