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

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

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

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

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

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

猜你在找的NoSQL相关文章