Blog Post

MongoDB -Calculating Collection Size

,

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.

CollectionSize

Calculating Size of All Collections

 

>cols = db.getCollectionNames();

// Iterate through each collection.

> cols.forEach(function(col) {

print (col +’-‘+ db[col].totalSize());

});

AllCollectionSize

 

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating