How does php paging particularly large data volumes?
Reply content:
How does php paging particularly large data volumes?
The paging method is as follows:
SELECT * FROM posts order by id desc limit $ page_size OFFSET $ offset
However, when $ offset is large, the speed will be slow.
In this case, you can use "Previous Page" and "next page" for paging, for example:
60-41 (Previous Page) 40-21 (current page) 20-01 (next page)
Next page (20 old articles ):
// Page. php? Id =-21 negative number indicates the next page old article here 21 indicates the ID of the bottom article on the current page. SELECT * FROM posts WHERE id <21 order by id desc limit 20;
Previous Page (20 new articles ):
// Page. php? Id = 40 positive number indicates the ID of the top article on the current page in the new article on the previous page. SELECT * FROM posts WHERE id> 40 order by id asc limit 20;
The obtained result is the ascending ID sequence. PHP uses the array_reverse reverse array to implement the descending output.
If negative numbers are not good, you can add an additional parameter, for example:
Page. php? Action = next & id = 21
Page. php? Action = prev & id = 40
The above describes a solution. I will talk about a latency association query.