Understanding mongo db explain

。_饼干妹妹 提交于 2019-12-04 22:18:43

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