-1

I have some questions about how pagination works, particularly when viewing the "firehose" at https://stackoverflow.com/questions. Right now, the paginated links look something like:

https://stackoverflow.com/questions?page=2&sort=newest

This means that when I click the "next" button, the next page is calculated based on the current state of Stack Overflow, rather than the state of the site when I first started paging through question. This means that "next" may in fact show me questions I have already seen, and if I'm a slow reader I may not actually make any forward progress.

This is a frustrating experience and makes it difficult to discover questions "outside of my comfort zone".

Would it make sense to modify the pagination mechanism such that it includes a reference to the base question from which the pages were initially calculated? E.g., if I start browsing and the first question is this one, pagination links might look something like:

https://stackoverflow.com/questions?page=2&base=47946141&sort=newest

In this model the server would calculate a list of questions older than the base, and use that to generate the pagination. I could always see newer questions simply by returning to https://stackoverflow.com/questions.

I realize that this is effectively proposing a "cursor" for paginated links. Is that crazy talk?

4
  • There's a recent question about this here but it never got an official answer.
    – ivarni
    Dec 22, 2017 at 19:04
  • I see that not only was that question heavily downvoted, but it also managed to never mention "pagination", thus foiling my attempts to see if this had already been asked. I hoped that I've provided a slightly more palatable phrasing of the question. Time will tell, I guess.
    – larsks
    Dec 22, 2017 at 19:08
  • 3
    I don't think this would really be feasible. Not only are new questions being added to the list, the existing questions are being re-sorted as they are voted on, questions are being closed/deleted, etc. Keeping the same order would require the order and selection of questions be cached specifically for you such that it doesn't change until you want it to.
    – Kevin B
    Dec 22, 2017 at 19:17
  • 1
    I figured "select all questions older than <x>" and then apply the same heuristics that are currently in use would be a relatively simple improvement, but I didn't actually realize that the list at /questions was sorted by anything other than chronological order. So maybe that wouldn't really help all that much.
    – larsks
    Dec 22, 2017 at 19:19

1 Answer 1

9

This is far from trivial to implement.

Say you take the "select all questions older than x" approach, what would the page number then be?

If each page contains 10 items, and there are 23 questions younger than x, you'd end up halfway through page 3:

page | questions
 1   |  1 - 10
 2   | 11 - 20
 3   | 21 - 30

Now what if you'd want to go to page 2? Where would you navigate to? To the range of items 14-23? Revert back to default pagination, 11-20? Then you'd be missing questions 21-23.

We haven't even touched handling deleted questions, yet. A base parameter would only shift the problem to a different index. If a question older than x is deleted, all questions after the deleted one shift forward, affecting every page after the one containing your base.

On the technical end, as far as databases are concerned, a TAKE X SKIP Y is fast. Comparing timestamps / ids isn't.


Long story short:

Timestamp based pagination is a pain to implement, and even more of a pain to explain to a normal user.

The current system is fast, easy to explain and easy to understand.

1
  • also, probably for the same reasons explained here, that's consistent with how pagination works in many sites. Actually, I don't remember knowing any site (with dynamic user-content like here) that uses timestamped snapshot of pages.
    – Pac0
    Jun 12, 2018 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .