Delete a collection from mongo db of huge size and reclaim the space

169 views
Skip to first unread message

Virendra Agarwal

unread,
Dec 6, 2013, 3:54:25 AM12/6/13
to mongod...@googlegroups.com
 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.

Sam Flint

unread,
Dec 6, 2013, 11:21:54 AM12/6/13
to mongod...@googlegroups.com
If you need the space back just dropDatabase. Use a different database everyday.  

Kenneth Gorman

unread,
Dec 7, 2013, 8:53:53 AM12/7/13
to mongod...@googlegroups.com
You always could just use a new DB for each day of the week, then drop the DB, which cleans up the files, and doesn’t require you to do repair or otherwise clean up.

-kg
> --
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb
>
> ---
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.

Virendra Agarwal

unread,
Dec 12, 2013, 4:11:00 AM12/12/13
to mongod...@googlegroups.com
I need to drop collection in that database not the complete db. So i need some operation which can reclaim the collection space 

Virendra Agarwal

unread,
Dec 12, 2013, 4:11:09 AM12/12/13
to mongod...@googlegroups.com

I need to drop collection in that database not the complete db. So i need some operation which can reclaim the collection space 

Asya Kamsky

unread,
Dec 15, 2013, 4:17:00 AM12/15/13
to mongodb-user
Right, we get that.  The suggestion is to change where you store this collection - instead of storing it in the same database you store other collections in, store it in its own database that you can drop nightly.

Asya



--
Reply all
Reply to author
Forward
0 new messages