It’s amazing to me that something as commonplace as pagination really isn’t a “solved” problem. Although, how often do people scroll through over 100 pages of data? It’s probably fine in almost all cases to just show the first 10 pages of data, and have a full-data export available for auditing purposes. So offset / limit is probably good enough most of the time.
I’ll add one more issue to the list - what if you want to paginate on data that’s stored in multiple different services? I come across this a lot. The only good solution I have is to create an index that combines all the data so you can paginate that. Seems like a lot of work though.
Although, how often do people scroll through over 100 pages of data? It’s probably fine in almost all cases to just show the first 10 pages of data
If you’ve got an application that has an infinite-scroll like UI where new items can be added somewhat frequently, you effectively need keyset pagination. Otherwise as you scroll you’ll see duplicates appear when new items get added to the “top” of the list, causing your offset to be “wrong”.
That’s true. That’s why I was surprised to realize that pagination isn’t “solved.” It’s something that every programmer uses as an optimization, yet there are still surprising subtleties.
It’s amazing to me that something as commonplace as pagination really isn’t a “solved” problem. Although, how often do people scroll through over 100 pages of data? It’s probably fine in almost all cases to just show the first 10 pages of data, and have a full-data export available for auditing purposes. So offset / limit is probably good enough most of the time.
I’ll add one more issue to the list - what if you want to paginate on data that’s stored in multiple different services? I come across this a lot. The only good solution I have is to create an index that combines all the data so you can paginate that. Seems like a lot of work though.
If you’ve got an application that has an infinite-scroll like UI where new items can be added somewhat frequently, you effectively need keyset pagination. Otherwise as you scroll you’ll see duplicates appear when new items get added to the “top” of the list, causing your
offset
to be “wrong”.That’s true. That’s why I was surprised to realize that pagination isn’t “solved.” It’s something that every programmer uses as an optimization, yet there are still surprising subtleties.
Probably build an offline index in the background periodically.
Yes that’s what I’m saying. But then that’s extra work just to be able to paginate that data.