Last active
January 24, 2023 07:54
-
-
Save danyanya/a420a5de87d80f7039b208c24d9ce532 to your computer and use it in GitHub Desktop.
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
# One line JS code to check MongoDB collection storageSize | |
var collectionNames = db.getCollectionNames(), stats = []; collectionNames.forEach(function (n) { stats.push(db.getCollection(n).stats()); }); stats = stats.sort(function(a, b) { return b['storageSize'] - a['storageSize']; }); for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment