MongoDB: determine total size of indexes in a database.
One of the most important things to keep in mind when setting up MongoDB for production environments, is that the total size of indexes fits in the RAM.
This query display the total size of the indexes in a mongo database.
var collections = db.getCollectionNames()
var totalIndexSize = 0;
collections.forEach(function (collectionName) {
var collection = db.getCollection(collectionName)
totalIndexSize += collection.totalIndexSize();
});
print("Total size of indexes: " + totalIndexSize + " bytes (" + (totalIndexSize / 1024 ) / 1024 + "MB)");
Written by Franklin Dattein
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mongodb
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#