We have a very big collection, and for getting a better performance, we want to limit the size of "active" collection.

That means, we have two collection: "active" and "inactive", we need to keep the data of last 90 days in "active" collection, and move the data before 90 days to "inactive" collection automatically.

Is any way that we can do this automatically with mongodb?

Or is there any other solution we can achieve this target? (get better performance for querrying data in 90 days without deleting old data)

  • "... get better performance for querying data in 90 days without deleting old data": Any query (find, update, delete or aggregation) on the collection can include a query filter specifying to select documents in the last 90 days. Create an index on the timestamp field (assuming there is a timestamp field on each document; if not create one with type Date). This way you can work with "active" data only and the index will ensure the query is performant. – prasad_ Jan 14 at 11:37
  • @prasad_, thank you prasad_, I will try it. – Woods Chen Jan 17 at 3:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.