0

I have a database which store historical data of sensors. Each time I could type a command 'get 1' to get 1,000 data from server. If user type a command 'get 2', he can retrieve another 1,000 data and the whole database is sorted by time. How to retrieve data with query? Also, I concern the performance of database.

This is one of the record format. I have more than 1 billions data in server.

enter image description here

2

1 Answer 1

1

You can make it by using $skip and $limit.

But a better solution is you get the first 1k documents and then you request another 1k documents with date. Such as below example.

First: 1k docs, date between them are 20210805 ~ 20211016. Second: $sort, { $match: {date: {$lt: 20210805}}}, $limit:1000

Sign up to request clarification or add additional context in comments.

1 Comment

Thank for you answer. My sampling time doesn't have fixed sampling time interval. I can't use match to do it. $skip may be a good solution in this database

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.