Useful script to find out MongoDB collections size and other statistics.
Studio 3T > IntelliShell
var dbs = db.getMongo().getDBNames();
for (adb of dbs) {
var colls = db.getSiblingDB(adb).getCollectionNames()
for (coll of colls) {
var info = db.getSiblingDB(adb).getCollection(coll).stats(1024);
if (info.ok) {
printjson({
ns: info.ns,
count: info.count,
size: info.size,
storageSize: info.storageSize,
nindexes: info.nindexes,
totalIndexSize: info.totalIndexSize
});
}
}
}
- Double click on
storageSizecolumn to sort by size descending
Reference: How to get MongoDB statistics for all collections? #Studio3T_AMA