Calculating Collection Size
We can get the size of a collections by using the shell’s functions
- db.collection.dataSize() : Returns data size in bytes for the collection.
- db.collection.storageSize() : Returns allocation size in bytes, including unused space.
- db.collection.totalSize() : Returns the data size plus the index size in bytes.

Calculating Size of All Collections
>cols = db.getCollectionNames();
// Iterate through each collection.
> cols.forEach(function(col) {
print (col +’-‘+ db[col].totalSize());
});

About Prashanth Jayaram
DB Technologist, Author, Blogger, Service Delivery Manager at CTS, Automation Expert, Technet WIKI Ninja, MVB and Powershell Geek
My Profile:
https://social.technet.microsoft.com/profile/prashanth jayaram/
http://www.sqlshack.com/author/prashanth/
http://codingsight.com/author/prashanthjayaram/
https://www.red-gate.com/simple-talk/author/prashanthjayaram/
http://www.sqlservercentral.com/blogs/powersql-by-prashanth-jayaram/
Connect Me:
Twitter @prashantjayaram
GMAIL
[email protected]
The articles are published in:
http://www.ssas-info.com/analysis-services-articles/
http://db-pub.com/
http://www.sswug.org/sswugresearch/community/