Measuring diskspace

52 views
Skip to first unread message

Tim

unread,
Sep 10, 2012, 8:29:10 AM9/10/12
to mongod...@googlegroups.com
Hello,

I want to measure diskspace with some testdata.

I inserted 100.000 data then 200.000 and so on.

1)
Which command is recommended to check the diskspace?
db.mycol.stats()?
I read the description of db.mycol.stats() [http://docs.mongodb.org/manual/reference/collection-statistics/]
I would look for "storagesize" (right?) - does the number stands for MB? (couldn't find that)

2) After inserting and measuring I would like to delete the data and insert data again.
I found a lot of information concerning that, but I'm not sure what to use.

Is db.mycol.remove() sufficient? Or do I have to use db.repairDatabase()? Or just db.runCommand({compact:'collectionname'}). for the single collection (There is only one collection).
I read that db.dropDatabase() is recommended sometimes. Do I have to config. my sharding set again after using db.dropDatabase()?

Which way is recommanded?

Best regards,
Tim

Mark

unread,
Sep 10, 2012, 2:21:17 PM9/10/12
to mongod...@googlegroups.com
Well, you have some problems. 
Mongo creates a new 2 gig file (assuming you have lots of data) once the previous file fills up with data, so in theory, you can have an extra 2 gigs that are empty. 

From db.stats()
I look at: dataSize + indexSize for the amount of data in the datafiles. 

To double check, I do a db.TABLE.stats() and add up the size + totalIndexSize for each table to the above. 

StorageSize I believe is the amount of space allocated within the total fileSize to documents, but it won't decrease in size. 
Filesize is the amount of diskspace on disk the database is taking up (which includes extra space). 

Check out:

Tim

unread,
Sep 12, 2012, 10:13:55 AM9/12/12
to mongod...@googlegroups.com
Hi Mark,
I read
http://docs.mongodb.org/manual/reference/collection-statistics/


What do you mean with some problems?
Is there always one 2 GB file for allocating diskspace?

How would you measure the diskspace and so on. Is the remove() function sufficent? How can I do a objective measurement?
Or can I ignore the space allocating fact and just insert data and measure that?

Best regards,
Tim

Mark Niel

unread,
Sep 20, 2012, 6:52:25 PM9/20/12
to mongod...@googlegroups.com
Sorry, didn't log into this account for a week, been busy!
Mongo creates a file for a database, I think 64 megs or something, and keeps doubling it when you need more diskspace for your database. 
So it creates a new file once the old file is getting filled up. 
Thus, your last file in the database could be up to 2 gigs of empty space. 
So, on the operating system, you will see a 2 gig file, but mongo you may not. 

Mongo has the "storage" size, which should match the os size as well.

There is actual space, and virtual space. 
The stats() functions will tell you what mongo thinks its allocating. 
The os will tell you the hard amount of diskspace being used. 
Both are useful. 
I tend to pay attention to the mongo stats if the os diskspace stats look good. 
Sometimes you might have 50 gigs of allocated space, but only 1 gig of actual data because the other 49 was deleted in mongo. 
Mark



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

Reply all
Reply to author
Forward
0 new messages