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
db.adminCommand({"currentOp": 1}) | |
// or | |
db.adminCommand({"currentOp": 1, "$ownOps" : true}) |
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
db.currentOp() | |
// or | |
db.currentOp({"$ownOps" : true}) |
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
db.adminCommand({ | |
"currentOp": true, | |
"op" : "query", | |
"planSummary": "COLLSCAN" | |
}) |
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
db.adminCommand({ | |
"currentOp": true, | |
"ns": /^guidebook\./, | |
"numYields" : {"$gte": 100} | |
}) |
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
db.adminCommand({ | |
"currentOp": true, | |
"waitingForLock" : true, | |
"$or": [ | |
{ "op" : { "$in" : [ "insert", "update", "remove" ] } }, | |
{ "query.findandmodify": { "$exists": true } } | |
] | |
}) |
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
db.adminCommand({ | |
"currentOp": true, | |
"microsecs_running" : {"$gte" : 300000} | |
}) | |
/* | |
// output for the above command | |
{ | |
"inprog": [{ | |
"host": "shyam-macbook.local:27017", | |
"desc": "conn", |
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
function restaurant() { | |
var dbName = 'guidebook'; | |
var cuisines = ['American', 'Chinese', 'Irish', 'Turkish', 'Italian', 'Mexican', 'Greek', 'Seafood', 'Indian', 'Japanese', 'Indian', 'Vegetarian', 'Hawaiian']; | |
var zipcodes = ["10030", "10471", "10112", "11426", "10039", "10035", "11005", "10307", "11692", "10044", "10026", "10280", "11233", "10103", "10121", "10282", "10473", "10281", "11436", "10153", "11433", "10057", "11242", "10111", "10122", "10168", "10107", "10000"]; | |
function queryByZip(zipcode) { | |
var query = {"address.zipcode" : zipcode}; | |
var coll = db.getSiblingDB(dbName).getCollection('restaurants'); | |
var items = coll.find(query).toArray(); | |
return items; |
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 i = 0; | |
while(i++<10) { | |
printjson(db.currentOp()); | |
// sleep for 10 ms if required. | |
sleep(10) | |
} |
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
#!/bin/sh | |
# download and import the restaurant sample data set | |
wget https://raw.githubusercontent.com/mongodb/docs-assets/primer-dataset/primer-dataset.json | |
mongoimport --db guidebook --collection restaurants --type json --file ./primer-dataset.json | |
# download and run the load generation script | |
wget https://goo.gl/BXHH2d -O labs-performance-restaurant.js | |
mongo guidebook --eval "load('./labs-performance-restaurant.js');r.performReads();" > /dev/null 2>&1 & | |
# open mongo shell and practice all the above use cases for currentOp |
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
// command to get readWrite privileges | |
db.getRole( "readWrite", { showPrivileges: true } ).privileges[0].actions | |
// output of above command | |
/* | |
[ | |
"changeStream", | |
"collStats", | |
"convertToCapped", | |
"createCollection", | |
"createIndex", |
OlderNewer