Unused index detection
Access count per index; zero ops = candidate to drop and reclaim write cost
mongosh --eval 'db.<name>.aggregate([{$indexStats:{}}]).forEach(i=>print(i.name,i.accesses.ops))'
- tool
- mongodb20 commands
More mongodb commands
-
mongosh --eval 'db.setProfilingLevel(1,{slowms:100}); db.system.profile.find().sort({millis:-1}).limit(5)'Capture ops slower than 100ms then read top offenders from system.profile
-
mongosh 'mongodb://user:pass@mongo:27017/dbname'Open interactive shell to a MongoDB instance
-
mongosh --eval 'rs.status()' mongodb://mongo:27017Show replica set members, lag, and election status
-
mongosh --eval 'db.stats()' mongodb://mongo:27017/mydbData size, storage size, collection count for a database
-
mongosh --eval 'db.myCollection.stats()' mongodb://mongo:27017/mydbDocument count, index sizes, storage for a collection