Profile slow queries
Capture ops slower than 100ms then read top offenders from system.profile
mongosh --eval 'db.setProfilingLevel(1,{slowms:100}); db.system.profile.find().sort({millis:-1}).limit(5)'
- tool
- mongodb20 commands
More mongodb commands
-
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
-
mongosh --eval 'db.currentOp({active:true,secs_running:{$gt:5}})' mongodb://mongo:27017Show operations running longer than 5 seconds