@H_301_3@MongoDB 提供了一个 explain 命令让我们获知系统如何处理查询请求。利用 explain 命令,我们可以很好地观察系统如何使用索引来加快检索,同时可以针对性优化索引。
- @H_301_3@>db.t5.ensureIndex({name:1})
- @H_301_3@>db.t5.ensureIndex({age:1})
- @H_301_3@>db.t5.find({age:{$gt:45}},{name:1}).explain()
- @H_301_3@{
- @H_301_3@"cursor":"BtreeCursorage_1",
- @H_301_3@"nscanned":0,
- @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":{
- @H_301_3@"age":[
- @H_301_3@[
- @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
- @H_301_3@]
- @H_301_3@]
- @H_301_3@}
- @H_301_3@}
@H_301_3@字段说明: cursor: 返回游标类型(BasicCursor 或 BtreeCursor) nscanned: 被扫描的文档数量 n: 返回的文档数量 millis: 耗时(毫秒) indexBounds: 所使用的索引
原文链接:https://www.f2er.com/nosql/204159.html