我们正在为当前在生产中运行的应用程序之一使用 Mongdb。
有时我们会遇到用户前端速度缓慢的情况(即数据加载到已登录的用户缓慢)
我们希望排除可能的缓慢问题。 我的问题是,有什么办法我们可以知道 Mongo DB 查询需要多长时间来响应?
非常感谢。
更新部分
谢谢,这是从 Mongo db 开发盒中获取的示例结果
{ "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" : "" }
但是从中我如何才能真正知道每个查询花费了多少时间?
最佳答案
使用分析器,设置db.setProfilingLevel(2)
来启用它。
和 db.system.profile.find().sort({$natural:-1})
查看记录
关于mongodb - 如何在生产环境中跟踪Mongo DB查询响应时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14209646/