Live data from Hacker News

We switched to cursor-based pagination

moderntreasury.com

1–10 of 118 posts

Re: We switched to cursor-based pagination

#4
I think the challenge is always the stateless nature of HTTP. It's pretty hard to keep a connection to the API server that has your database cursor.

Everything else has big tradeoffs. You can make sure your rows are sortable by a specific column, but that means your searches must all be sorted by that column.

You can save the results of a search and page through it, but that's a lot of I/O.

You can not do any of the above, but then you run the risk of non-deterministic pagination (I went back and because someone added/deleted a row, that page is slightly different now). You also can't really link to it.

These things might all be fine. In my experience though, you run into people who really want to do search in way A, and will use the tradeoffs for way B/C/D to argue against it, as though A has no tradeoffs.

Re: We switched to cursor-based pagination

#7
post #3

TL;DR: The headline. TFA doesn't really add any information.

Well, except that TFA explains what DB cursors are and why they are faster than page offsets (because they skip DB entries).

It needs to talk about how to actually implement it. Most articles like this one mention its existence and why it's good, but generally stop there.

Re: We switched to cursor-based pagination

#8
post #5

Reminds me of Markus Winand who hands out stickers on database conferences banning offset. His site is a great resource for anyone wanting to take a deeper dive on SQL performance: https://use-the-index-luke.com/sql/partial-results/fetch-nex...

Which in turn reminds me of: http://simonwillison.net/2022/Aug/16/efficient-pagination-us...

Re: We switched to cursor-based pagination

#9
post #5

Reminds me of Markus Winand who hands out stickers on database conferences banning offset. His site is a great resource for anyone wanting to take a deeper dive on SQL performance: https://use-the-index-luke.com/sql/partial-results/fetch-nex...

So basically do it like Reddit?

https://old.reddit.com/?count=25&after=t3_wtpvdp

I noticed Reddit's pagination has that "after" parameter, which points to the last post on the current page.

It glitches out if the last item is deleted by moderators, but otherwise it works smoothly.

Re: We switched to cursor-based pagination

#10
post #3

TL;DR: The headline. TFA doesn't really add any information.

Well, except that TFA explains what DB cursors are and why they are faster than page offsets (because they skip DB entries).

TFA isn't talking about that kind of cursor.
Post reply on HN