Skip to content

Instantly share code, notes, and snippets.

@zizkebab
Created May 28, 2018 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zizkebab/93b920fb05a2e36010a0c79b979db9b3 to your computer and use it in GitHub Desktop.
Save zizkebab/93b920fb05a2e36010a0c79b979db9b3 to your computer and use it in GitHub Desktop.
Get MongoDB collections' index size, data size and total size.
use mydb
db.getCollectionNames().forEach(function(x){print(x + ": " + db.getCollection(x).totalIndexSize()/(1024*1024*1024) + ", " + db.getCollection(x).dataSize()/(1024*1024*1024) + ", " + db.getCollection(x).totalSize()/(1024*1024*1024))})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment