Pawan
Pawan

Reputation: 32321

How to track Mongo DB query response time in Production Environment?

We are uisng Mongdb for one of our Application that is running in production currently .

Sometimes we are experiencing slowness in the User Front End (ie the Data is loading slowly to the User who has loggged in )

We want to rule out the possible issues of the slowness . My question is , is there any way we can know how much time the Mongo DB query is taken to respond ??

Thank you very much .

Updated Part

Thanks , this was a sample result taken from the Mongo db develoment box

{ "ts" : ISODate("2013-01-02T19:11:16.822Z"), "op" : "query", "ns" : "ravi.system.indexes", "query" : { "expireAfterSeconds" : { "$exists" : true } }, "ntoreturn" : 0, "ntoskip" : 0, "nscanned" : 1, "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(65), "w" : NumberLong(0) }, "timeAcquiringMicros" : { "r" : NumberLong(4), "w" : NumberLong(5) } }, "nreturned" : 0, "responseLength" : 20, "millis" : 0, "client" : "0.0.0.0", "user" : "" }

{ "ts" : ISODate("2013-01-02T19:10:16.822Z"), "op" : "query", "ns" : "ravi.system.indexes", "query" : { "expireAfterSeconds" : { "$exists" : true } }, "ntoreturn" : 0, "ntoskip" : 0, "nscanned" : 1, "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(66), "w" : NumberLong(0) }, "timeAcquiringMicros" : { "r" : NumberLong(4), "w" : NumberLong(4) } }, "nreturned" : 0, "responseLength" : 20, "millis" : 0, "client" : "0.0.0.0", "user" : "" }

But from this how can i really know what time is taken for each query ??

Upvotes: 3

Views: 3465

Answers (1)

slggamer
slggamer

Reputation: 217

use profiler, set db.setProfilingLevel(2) to enable it. and db.system.profile.find().sort({$natural:-1}) to view the records

Upvotes: 9

Related Questions