Reputation: 687
I am started using MongoDB few days ago, and i have problem in understanding some database architecture. If i execute the query db.stats(); i had got filesize ,datasize,storagesize & indexsize. While i am surfing i found that the following:
Storagesize = datasize + free space allocated for collection
datasize = database size utilised by MongoDB
Here, I could not understand the representaion of filesize & datasize reprsentation. For datasize --> indexsize is also included?. Please provide a precise solution for the specified attributes and please do correct me if i mentioned anythng wrong.
Advance Thanks,
Upvotes: 8
Views: 5165
Reputation: 721
As explained in this post about the different MongoDB performance metrics you should monitor (with MMAPv1), here are all the storage size metrics returned by dbStats that you should track:
dataSize
measures the space taken by all the documents and padding in the database. Because of padding, dataSize
decreases if documents are deleted but not when they shrink or get bigger following an update—those operations just add to or borrow from the document’s padding.indexSize
returns the size of all indexes created on the database.storageSize
measures the size of all the data extents in the database. With MMAPv1, it’s always greater than or equal to dataSize
because extents contain free space not yet used or freed by deleted and moved documents. storageSize
is not affected when documents shrink or are moved.fileSize
corresponds to the size of your data files. It’s obviously always larger than storageSize
and can be seen as the storage footprint of you database on disk. It decreases only if you delete a database and is not affected when collections, documents, or indexes are removed.Here is a diagram with the different important storage metrics returned by dbStats: NOTE: With the MMAPv1 storage engine, MongoDB pre-allocates extra space on the disk to documents so efficient in-place updates are possible since documents have room to grow without having to be relocated. This extra space is called padding.
Upvotes: 2
Reputation: 1782
I realize this is an older question, but I figured I'd link to the official docs for db.stats()
for anyone else looking for similar info (as I was).
Database Statistics Reference :: Fields
Upvotes: 1
Reputation: 18595
Upvotes: 18