1

I am showing list of users in descending order based on their last activity time.

Problem:

Let's assume pagination of 3 records per page, and first 3 users shown based on their recent activity, now before user went to page 2, the next set of users have made some activities, therefore those were skipped and the users shown on page 1 are loaded again.

How this can be addressed ?

kamal pal
  • 4,187
  • 5
  • 25
  • 40
  • 1
    this is standard behaviour – inarilo May 27 '17 at 06:59
  • if it's absolutely necessary, you can fetch the ids in order first, and then fetch 3 records at a time from that. – inarilo May 27 '17 at 07:01
  • I don't think it's preferable to fetch all id from user table, this is why pagination is used. – kamal pal May 27 '17 at 07:05
  • it's the only way you can know which records to display next, if you wish to maintain the order at that point in time. and just fetching ids is not an issue unless you have a huge number of records. i assume your ids are autoincrement numbers. – inarilo May 27 '17 at 07:36
  • Probably worth noting here that backing up as "standard behavior", you can actually spend some time on this very site watching a tag with any reasonable volume. You will then notice that as new posts come in you could scroll down to the bottom of the page and look at the last couple of posts. Then go to the next page and you will find those posts you saw at the bottom will be at the top of the next page. So this is nothing new. If it's that much of an issue to you then perhaps you should implement a similar "new activity" notification, just like SO does. – Neil Lunn May 27 '17 at 08:59
  • You can actually mitigate some of the effect if you are implementing a "forward paging" methodology. Basic principles are keeping a "moderate list" of seen id values, along with filtering out the last seen value in a "range" ( i.e your "description" here ). See the obscurely named [Implementing Pagination In MongoDB](https://stackoverflow.com/questions/28105009/implementing-pagination-in-mongodb/28105442#28105442) question and answer on this very site. – Neil Lunn May 27 '17 at 09:04

0 Answers0