I am having a mongo shard set up in my production environment. In my application i create db on daily basis as my single day db size reaches to 18 GB.
I have a collection in my DB which logs raw data for the hits of my site. I use this collection for single day only as whole raw data is converted to aggregated data by my db script.
I want to delete this collection at the end of day but my confusion is due to big size of this collection(almost 6 GB) and my db size exceeds 17 GB is it safe to use repair Database command.
Could you please suggest me a way to do this.
MongoDB (at at 2.4) currently allocates storage at a database level. You are correct that you would need to run the
repairDatabase
command in order to reclaim the preallocated storage.If that space is going to be reused again soon (i.e. for the next day of raw data) you could just leave it allocated rather than running a repair. If you process different amounts of data every day, this may use some excessive storage as you'll basically remain at the "high watermark" where you've had the most storage allocated.
If you're concerned about the space usage, a better approach would be to add the raw data into a separate database that you can drop when you no longer need the raw data (i.e. your raw data goes into a separate DB/collection per day instead of just a separate collection).