How to execute SQL query page if it was offset?

Hello. I have a sample of posts from the database tartronovaya they rated and ID.

I have done Ajax loading. Do a sample of 20 per page. And with each increase the page loading in 1.

The problem arose when there are new posts that are above, there is a shift in the number of new posts. If, for example, added 2 new post and I start to load then repeat the last 2 post.

And understandably so. And how then to do better?
June 5th 19 at 21:01
2 answers
June 5th 19 at 21:03
And this is just another reason why pagination is not necessary to use offset. (the first reason is the productivity offset)
Pass values sort last visible list item and request continued the list, and not offset.
June 5th 19 at 21:05
Get the number of records in the sample before each request, and calculate the pagination with the new data.
But not in the sample to make a new parameter, for example (rating*ID+ID) and when uploading to watch for this option was less than the previous? - conor.Ko commented on June 5th 19 at 21:08
I think you in this case, it is easier to cache the data somewhere, and after some time to update, notifying about change of users. - daron commented on June 5th 19 at 21:11
yeah I already did as you said. I hope the rules will be to work - conor.Ko commented on June 5th 19 at 21:14

Find more questions by tags SQL