[mongodb] explain

mongodb 2015. 10. 12. 20:34


mongodb 는 explain을 제공한다.


3.0 부터 $explain은 deprecated되었고, db.collection.explain(http://docs.mongodb.org/manual/reference/method/db.collection.explain/#db.collection.explain) 또는 cursor.plain(http://docs.mongodb.org/manual/reference/method/cursor.explain/#cursor.explain)을 사용해야 한다. (3.0부터 추가)





db.collection.explain()은 디폴트로 verbose하게 정보를 전달하며, 사용법은 쉽다. 


db.collection.explain().명령어()


예)

db.collection.explain().find()

db.collection.explain().find({})

db.collection.explain().count()




특정 결과는 다음과 같다. 최적화 관련 내용인 queryPlanner와 server 정보를 보여준다.


replset:PRIMARY> db.times.explain().find({'sid':1})

{

"queryPlanner" : {

"plannerVersion" : 1,

"namespace" : "google.times",

"indexFilterSet" : false,

"parsedQuery" : {

"sid" : {

"$eq" : 1

}

},

"winningPlan" : {

"stage" : "FETCH",

"inputStage" : {

"stage" : "IXSCAN",

"keyPattern" : {

"profileId" : 1

},

"indexName" : "sid_1",

"isMultiKey" : false,

"direction" : "forward",

"indexBounds" : {

"sid" : [

"[1.0, 1.0]"

]

}

}

},

"rejectedPlans" : [ ]

},

"serverInfo" : {

"host" : "google056",

"port" : 27017,

"version" : "3.0.6",

"gitVersion" : "1234"

},

"ok" : 1

}

'mongodb' 카테고리의 다른 글

[mongodb] master 노드 변경하기  (0) 2015.10.30
[mongodb] replica set 만들기  (0) 2015.10.26
[mongodb] collection 개수 구하기  (0) 2015.10.12
[mongodb] 모니터링하기  (0) 2015.10.12
[mongodb] 3.0부터 ensureIndex는 deprecated됨  (0) 2015.10.12
Posted by '김용환'
,