Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
113 views
in Technique[技术] by (71.8m points)

mysql - Paginated query from Database

I have to do paginated query to return the list to frontend. And this query should be sorted in descending order of their timestamp of transaction i.e. most recent recent transaction should be the 1st element in the list and oldest transaction should be the last element in the list. But I am facing an issue :

Scenario :

Total no of records : 41
Page Size : 5
Query1 : 
        R1,R2,R3,R4,R5
Query2 :
        R6,R7,R8,R9,R10


I have served the top 10 records in two pages and now I have to return the next set of results for 
3rd page and parallely a new transaction has been done. So the total no of records is 42 now, and 
I will do sorting as per timestamp, and will end up in returning R10 again in page no 3, as now there will
be a new record in the top. Also I won't be able to show the newest record as I have already served the 
1st page.

How to solve this scenario? The DB is MySQL/MongoDB. Sometimes I need to serve this from ElasticSearch as well.

question from:https://stackoverflow.com/questions/65897191/paginated-query-from-database

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...