Last active
August 29, 2015 14:07
-
-
Save wzr/8b796a80c1f284d6c0fb to your computer and use it in GitHub Desktop.
Mongo stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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