Data purging - best approach

98 views
Skip to first unread message

Krishna Kumar C

unread,
Aug 4, 2016, 4:06:37 PM8/4/16
to mongodb-user
Hi,

We need to maintain 4 months records in production after which we can purge the data. So i was planning to create a collection with 4 months and delete it manually.

I couldn't find any documentation in Java async driver api db.getCollection about mentioning a time period. Do you know how to create a collection specifying a time period?


Also, is this the best approach or should i use the TTL feature https://docs.mongodb.com/manual/tutorial/expire-data/


Regards
Krishna

Ross Lawley

unread,
Aug 5, 2016, 4:43:20 AM8/5/16
to mongod...@googlegroups.com
Hi Krishna,

A TTL index is a great way to automatically achieve your goal for purging data based on age and sounds ideal for your use case.  The alternative would be to manually delete the data from the collection using the MongoCollection#deleteMany method and providing a filter that covers the data to be purged.

Ross

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/5a6568c0-3a87-44dc-ac98-25218a5472b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--


{ name     : "Ross Lawley",
  title    : "Senior Software Engineer",
  location : "London, UK",
  twitter  : ["@RossC0", "@MongoDB"],
  facebook :"MongoDB"}

Krishna Kumar C

unread,
Aug 8, 2016, 1:17:14 AM8/8/16
to mongodb-user
Thanks Ross for the reply.

Last week i attended the "Back to Basics Webinar 6: Production Deployment" webinar from MongoDB. 

I asked the same question there, the reply from the presenter was to create a collection for 4 months and then manually delete it. Not sure how to implement it though. In our case the collection is updated with incoming messages, so as you said TTL seems to be the safe option.
 
Appreciate your help.

regards
Krishna
Reply all
Reply to author
Forward
0 new messages