I have a table with news. Let's call this table
Fill the first and last row id or timestamp of the page in the application client. If it is a web app then the
previous links would be something like:
<a href="example.com/news?firstRowId=40">Previous</a> <a href="example.com/news?lastRowId=70">Next</a>
Then pass the value of the one you receive from the client to the query and the other as
select * from news where (uid > :lastRowId or :lastRowId is null) and (uid < :firstRowId or :firstRowId is null) order by uid desc limit 20
The same logic for the insertion timestamp. It is very unlikely that two insertions would happen at the same millisecond but if the id is sequential then use the id.