Skip to content

Instantly share code, notes, and snippets.

@wzr
Last active August 29, 2015 14:07
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 wzr/8b796a80c1f284d6c0fb to your computer and use it in GitHub Desktop.
Save wzr/8b796a80c1f284d6c0fb to your computer and use it in GitHub Desktop.
Mongo stuff
# http://joey.aghion.com/listing-mongodb-collections-by-size/
function du () {
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) {
print(stats[c]['ns'] + ": " + Math.round(stats[c]['size']/1048576) + "MB (" + Math.round(stats[c]['storageSize']/1048576) + "MB)");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment