深入讲解MongoDB的慢日志查询(profile)

分类:文章教程 日期: 点击:0

前言

说到MongoDB的慢日志分析,就不得不提到profile分析器,profile分析器将记录的慢日志写到system.profile集合下,这个集合是一个固定集合。我们可以通过对这个集合的查询,来了解当前的慢日志,进而对数据库进行优化。

整体环境

MongoDB 3.2.5

实战

Part1:输出示范

在查询system.profile的时候,我们能够观察到所有的操作,包括remove,update,find等等都会被记录到system.profile集合中,该集合中包含了诸多信息,如:

{
“op” : “query”,
“ns” : “test.c”,
“query” : {
“find” : “c”,
“filter” : {
“a” : 1
}
},
“keysExamined” : 2,
“docsExamined” : 2,
“cursorExhausted” : true,
“keyUpdates” : 0,
“writeConflicts” : 0,
“numYield” : 0,
“locks” : {
“Global” : {
“acquireCount” : {
“r” : NumberLong(2)
}
},
“Database” : {
“acquireCount” : {
“r” : NumberLong(1)
}
},
“Collection” : {
“acquireCount” : {
“r” : NumberLong(1)
}
}
},
“nreturned” : 2,
“responseLength” : 108,
“millis” : 0,
“execStats” : {
“stage” : “FETCH”,
“nReturned” : 2,
“executionTimeMillisEstimate” : 0,
“works” : 3,
“advanced” : 2,
“needTime” : 0,
“needYield” : 0,
“saveState” : 0,
“restoreState” : 0,
“isEOF” : 1,
“invalidates” : 0,
“docsExamined” : 2,
“alreadyHasObj” : 0,
“inputStage” : {
“stage” : “IXSCAN”,
“nReturned” : 2,
“executionTimeMillisEstimate” : 0,
“works” : 3,
“advanced” : 2,
“needTime” : 0,
“needYield” : 0,
“saveState” : 0,
“restoreState” : 0,
“isEOF” : 1,
“invalidates” : 0,
“keyPattern” : {
“a” : 1
},
“indexName” : “a_1”,
“isMultiKey” : false,
“isUnique” : false,
“isSparse” : false,
“isPartial” : false,
“indexVersion” : 1,
“direction” : “forward”,
“indexBounds” : {
“a” : [
“[1.0, 1.0]”
]
},
“keysExamined” : 2,
“dupsTested” : 0,
“dupsDropped” : 0,
“seenInvalidated” : 0
}
},
“ts” : ISODate(“2015-09-03T15:26:14.948Z”),
“client” : “127.0.0.1”,
“allUsers” : [ ],
“user” : “”}

标签:

网站声明

1、本站所有软件和资料来源互联网,仅供个人学习和研究使用,不得用于任何商业用途。
2、如有侵犯您商标权、著作权或其他合法权利的,请联系我们,本站将在第一时间对此进行核实并处理。
3、本站所有可下载资源,都是按照“原样”提供,本站并未对其做过任何改动。本站不保证本站提供的下载资源的准确性、安全性和完整性。同时,本站也不承担用户因使用这些下载资源对自己和他人造成任何形式的损失或伤害。
4、继续浏览本站,即代表您遵守此声明。