Understanding mongo db explain

烂漫一生 提交于 2019-12-22 01:13:11

问题


I fired a query and tried to explain it on mongo console and got

"isMultiKey" : true,
"n" : 8,
"nscannedObjects" : 17272,
"nscanned" : 17272,
"nscannedObjectsAllPlans" : 21836,
"nscannedAllPlans" : 21836,
"scanAndOrder" : true,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 184,

Most of the things are explained in http://www.mongodb.org/display/DOCS/Explain, but I cannot understand what does nscannedObjectsAllPlans, nscannedAllPlans means. Can anyone help?

Thanks


回答1:


nscanned and nscannedObjects report results for the winning plan.

nscannedAllPlans and nscannedObjectsAllPlans report results for all plans

For example:

>t = db.jstests_explainb;
>t.drop();

>t.ensureIndex( { a:1, b:1 } );
>t.ensureIndex( { b:1, a:1 } );

>t.save( { a:0, b:1 } );
>t.save( { a:1, b:0 } );

>t.find( { a:{ $gte:0 }, b:{ $gte:0 } } ).explain( true );
{
  "cursor": "BtreeCursor a_1_b_1",
  "isMultiKey": false,
  "n": 2,
  "nscannedObjects": 2,
  "nscanned": 2,
  "nscannedObjectsAllPlans": 6,
  "nscannedAllPlans": 6,
  "scanAndOrder": false,
  "indexOnly": false,
  "nYields": 0,
  "nChunkSkips": 0,
  "millis": 2,
...
}


来源:https://stackoverflow.com/questions/12510974/understanding-mongo-db-explain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!