Skip to content

Instantly share code, notes, and snippets.

@kylemclaren
Forked from joeyAghion/mongodb_collection_sizes.js
Last active November 25, 2021 11:41
Show Gist options
  • Save kylemclaren/fbb8c585f8047ee69e9b to your computer and use it in GitHub Desktop.
Save kylemclaren/fbb8c585f8047ee69e9b to your computer and use it in GitHub Desktop.

Revisions

  1. @joeyAghion joeyAghion revised this gist Sep 13, 2013. 1 changed file with 4 additions and 11 deletions.
    15 changes: 4 additions & 11 deletions mongodb_collection_sizes.js
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,4 @@
    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'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")");
    }
    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'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
  2. @joeyAghion joeyAghion revised this gist Sep 10, 2013. 1 changed file with 9 additions and 3 deletions.
    12 changes: 9 additions & 3 deletions mongodb_collection_sizes.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,11 @@
    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'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
    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'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")");
    }
  3. @joeyAghion joeyAghion created this gist Sep 10, 2013.
    5 changes: 5 additions & 0 deletions mongodb_collection_sizes.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    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'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }