Created
June 11, 2020 21:26
-
-
Save anujku/37aa1677ace8c7a8c0546c81ac8bcff8 to your computer and use it in GitHub Desktop.
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
https://docs.mongodb.com/manual/administration/monitoring/ | |
// all queries that do a COLLSCAN | |
db.system.profile.find({"planSummary":{$eq:"COLLSCAN"}, | |
"op" : {$eq:"query"}}).sort({millis:-1}) | |
// 5 secs more | |
db.currentOp().inprog.forEach( | |
function(op) { | |
if(op.secs_running > 5) printjson(op); | |
} | |
) | |
// any query or command doing range or full scans | |
db.system.profile.find({"nreturned":{$gt:1}}) | |
// top ten slowest queries | |
db.system.profile.find({"op" : {$eq:"query"}}, { | |
"query" : NumberInt(1), | |
"millis": NumberInt(1) | |
} | |
).sort({millis:-1},{$limit:10}).pretty() | |
//find all queries that take more than ten milliseconds, in descending order, | |
displaying both queries and aggregations | |
db.system.profile.find({"millis":{$gt:10}}) .sort({millis:-1}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment