[DOCS-77] Should the storageSize sum of all collections of one database match the size on disk? Created: 08/Nov/11  Updated: 29/Nov/12  Resolved: 08/Nov/11

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Nolte Assignee: Sam Kleinman (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

ext4, MongoDB 2.0.0


Participants:
Days since reply: 12 years, 15 weeks, 1 day ago

 Description   

size = 0; db.getCollectionNames().forEach(function(c)

{ size += db[c].stats().storageSize }

} => 80401852864

or

db.stats()
{
"db" : "database_name",
"collections" : 13,
"objects" : 23654813,
"avgObjSize" : 3204.532793558757,
"dataSize" : 75802623984,
"storageSize" : 80401864384,
"numExtents" : 124,
"indexes" : 23,
"indexSize" : 2059164704,
"fileSize" : 184527355904,
"nsSizeMB" : 16,
"ok" : 1
}

vs

du -chs database_name.* => 172G

Shouldn't these value roughly match?



 Comments   
Comment by Sam Kleinman (Inactive) [ 08/Nov/11 ]

Hi,

I'm glad to hear that this fixed your problem.

Don't hesitate to send questions to the Google group in the future if you have issues.

Regards,
sam

Comment by Nolte [ 08/Nov/11 ]

Hi,

thanks for your help - db.stats().fileSize matches. Thanks

Comment by Sam Kleinman (Inactive) [ 08/Nov/11 ]

Hello,

The value of `du` should (and I believe does) more closely reflect the "fileSize" field (including "nsSizeMB") This value is likely larger than "storageSize" because of Padding Factor and data file preallocation. See the following documents for more information. The following documents may help explain this further:

http://www.mongodb.org/display/DOCS/Padding+Factor

http://www.mongodb.org/display/DOCS/Excessive+Disk+Space

You may find a better/more timely response for questions like these in the "mongo-uesr" group. You can find that here:

http://groups.google.com/group/mongodb-user

Cheers,
sam

Generated at Thu Feb 08 07:37:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.