I keep on seeing this in my log/development.log, and I am wondering whether this query is actually being executed in my database:
MONGODB (0ms) socialcrunch_development['tags'].find({:_id=>"secrets"}).limit(-1).sort([[:_id, :asc]])
Ho can I see the queries being executed on my mongo db, so I can count them, should they all typically be .find commands, or should i being looking for something else?
The db. currentOp() command provides means to find all the queries that are currently running on your MongoDB server. The optional fields can be further leveraged to help filter the results to specific criteria.
To open up the MongoDB shell, run the mongo command from your server prompt. By default, the mongo command opens a shell connected to a locally-installed MongoDB instance running on port 27017 . Try running the mongo command with no additional parameters: mongo.
You can also view access the live query execution plan by right-clicking on a selected query in Management Studio and then click Include Live Query Statistics.
The only foolproof method of determining whether a collection scan was performed is to compare the index keys with the match criteria from the query.
Listing all the databases in mongoDB console is using the command show dbs .
Print all active reads:
db.currentOp().inprog.forEach(
function(d){
if(d.waitingForLock && d.lockType != "read")
printjson(d)
})
Print all active writes:
db.currentOp().inprog.forEach(
function(d){
if(d.waitingForLock && d.lockType != "write")
printjson(d)
})
You can get a lot more granular if you like by using currentOp.op
to filter by a specific operation type (insert, update, delete, etc).
Check out the following page from MongoDB.org's documentation for more info: http://docs.mongodb.org/manual/reference/current-op/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With