Limit database size and show how much space is left

83 views
Skip to first unread message

Octavian Covalschi

unread,
Jul 3, 2012, 1:54:36 PM7/3/12
to mongod...@googlegroups.com
Hi,

Is %subj% even possible?

Right now I'm limiting by using --quota and --quotaFiles, which works in a way, but I'm not sure  how much space I've got left... is there a way to implement this? I need to make a small pie chart to display that.

The only solution I'm thinking is to use db.stats() and "fileSize". So, fileSize would be 100%, but dataSize would be the actual used...

Is there a better approach?

Thanks.

Kevin Matulef

unread,
Jul 3, 2012, 2:37:09 PM7/3/12
to mongod...@googlegroups.com
Unfortunately there's no built in flag to cap the total database size. As you've discovered, the --quota option will limit the number of data files and hence the total filesize.  But figuring out the remaining space is a little tricky, since some of the space in the datafiles is for indexes.  Also, if you're deleting documents, then fragmentation in the data files might mean that not all of the remaining space is usable.  fileSize minus dataSize will give you a rough estimate of the remaining space, but it won't be strictly accurate, so should be taken with a grain of salt.  .  

-Kevin

Octavian Covalschi

unread,
Jul 3, 2012, 2:56:02 PM7/3/12
to mongod...@googlegroups.com
OK, looks like I need a different approach.

Is db.stats() an expensive operation? Would it impact performance if I'll run it say, every 1min?

Thanks!

--
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

Octavian Covalschi

unread,
Jul 3, 2012, 3:05:45 PM7/3/12
to mongod...@googlegroups.com
Never mind, I just found an older message where Scott has written: "It takes a read lock, and has to calculate some numbers from the extents; it is not a very costly operation. "

So, I think I'll be running a cronjob script to get current data size... 

Thanks!
Reply all
Reply to author
Forward
0 new messages