Skip to content

Instantly share code, notes, and snippets.

View chrisbolin's full-sized avatar
❤️

Chris Bolin chrisbolin

❤️
View GitHub Profile
@chrisbolin
chrisbolin / mongodb-collection-sizes.js
Last active October 8, 2015 17:28 — forked from joeyAghion/mongodb_collection_sizes.js
List mongodb collections in descending order of storageSize. Helpful for finding largest collections.
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['storageSize'] - a['storageSize']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['storageSize']); }