Last active
October 16, 2020 14:34
-
-
Save karan9/a4591cd0a04f73893b24b288491077cb to your computer and use it in GitHub Desktop.
Returns number of indexes on each collection for a given database
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
var colls = db.getCollectionNames(); | |
var ret = []; | |
colls.forEach(function(coll) { | |
var indexes = db.getCollection(coll).getIndexes(); | |
var len = indexes.length | |
if (len >= 10) { | |
ret.push({ "name": coll, "length": len, "data": indexes}); | |
} | |
}) | |
printjson(ret) |
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
var colls = db.getCollectionNames(); | |
var ret = []; | |
colls.forEach(function(coll) { | |
var indexes = db.getCollection(coll).getIndexes(); | |
var len = indexes.length | |
ret.push({ "name": coll, "length": len, "data": indexes}); | |
}) | |
printjson(ret) |
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
var colls = db.getCollectionNames(); | |
var ret = []; | |
colls.forEach(function(coll) { | |
var indexes = db.getCollection(coll).getIndexes(); | |
var stats = db.getCollection(coll).aggregate( [ { $indexStats: { } } ] ); | |
var len = indexes.length | |
ret.push({ "name": coll, "length": len, "data": stats._batch}); | |
}) | |
printjson(ret) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment