Thoughts on Arbitrary Pagination
Pagination is the act of breaking a data set into multiple pages to limit the amount of data that has to be processed and sent by a server at once. We’re going to be changing how pagination works on crates.io, and I wanted to share some musings about the issues with supporting this as a generic abstraction. While I’m going to be talking about some PostgreSQL internals in this article, the general ideas presented apply to any SQL database.
The most common form of pagination uses page numbers. This is done by having numbered page links shown towards the bottom of the UI, and including
?page=5 in the URL. Often there are also links for next page, previous page, first page, and last page. The UI might look like this.
This form of pagination is implemented on the server by adding an offset to the query. The total is also needed to know how many pages there actually...
Continue reading →