Nosql Mongodb之旅(19)—MongoDB explain执行计划

前端之家收集整理的这篇文章主要介绍了Nosql Mongodb之旅(19)—MongoDB explain执行计划前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

MongoDB 提供了一个 explain 命令让我们获知系统如何处理查询请求。利用 explain 命令,我们可以很好地观察系统如何使用索引来加快检索,同时可以针对性优化索引。

  1. >db.t5.ensureIndex({name:1})
  2. >db.t5.ensureIndex({age:1})
  3. >db.t5.find({age:{$gt:45}},{name:1}).explain()
  4. {
  5. "cursor":"BtreeCursorage_1",
  6. "nscanned":0,
  7. "nscannedObjects":0,108); list-style:decimal-leading-zero outside; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> "n":0,108); list-style:decimal-leading-zero outside; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> "millis":0,108); list-style:decimal-leading-zero outside; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> "nYields":0,108); list-style:decimal-leading-zero outside; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> "nChunkSkips":0,108); list-style:decimal-leading-zero outside; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> "isMultiKey":false,108); list-style:decimal-leading-zero outside; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> "indexOnly":false,108); list-style:decimal-leading-zero outside; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> "indexBounds":{
  8. "age":[
  9. [
  10. 45,108); list-style:decimal-leading-zero outside; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> 1.7976931348623157e+308
  11. ]
  12. ]
  13. }
  14. }

字段说明:  cursor: 返回游标类型(BasicCursor 或 BtreeCursor)  nscanned: 被扫描的文档数量  n: 返回的文档数量  millis: 耗时(毫秒)  indexBounds: 所使用的索引

原文链接:https://www.f2er.com/nosql/204159.html

猜你在找的NoSQL相关文章