资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

MongoDB中怎么查看执行计划方法

这期内容当中小编将会给大家带来有关MongoDB中怎么查看执行计划方法,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

专业成都网站建设公司,做排名好的好网站,排在同行前面,为您带来客户和效益!成都创新互联公司为您提供成都网站建设,五站合一网站设计制作,服务好的网站设计公司,成都网站制作、做网站负责任的成都网站制作公司!

> db.chenfeng.find()
{ "_id" : ObjectId("5714419cf7c81959e12a904e"), "age" : 1, "name" : "duansf" }
{ "_id" : ObjectId("571441a3f7c81959e12a904f"), "age" : 2, "name" : "duansf" }
{ "_id" : ObjectId("571441a7f7c81959e12a9050"), "age" : 3, "name" : "duansf" }
{ "_id" : ObjectId("571441abf7c81959e12a9051"), "age" : 4, "name" : "duansf" }
{ "_id" : ObjectId("571442b0f7c81959e12a9052"), "age" : 5, "name" : "duansf" }
{ "_id" : ObjectId("571442bcf7c81959e12a9053"), "age" : 6, "name" : "duansf" }
>


> db.chenfeng.find().explain()
{
        "cursor" : "BasicCursor",
        "isMultiKey" : false,
        "n" : 6,
        "nscannedObjects" : 6,
        "nscanned" : 6,
        "nscannedObjectsAllPlans" : 6,
        "nscannedAllPlans" : 6,
        "scanAndOrder" : false,
        "indexOnly" : false,
        "nYields" : 0,
        "nChunkSkips" : 0,
        "millis" : 0,
        "server" : "XCC-Duanshufeng:27017",
        "filterSet" : false
}
>

加hint强制使用索引方法,这点和关系数据库特别像:
> db.chenfeng.find().hint({age:6}).explain()
{
        "cursor" : "BtreeCursor idx_age_6",
        "isMultiKey" : false,
        "n" : 6,
        "nscannedObjects" : 6,
        "nscanned" : 6,
        "nscannedObjectsAllPlans" : 6,
        "nscannedAllPlans" : 6,
        "scanAndOrder" : false,
        "indexOnly" : false,
        "nYields" : 1,
        "nChunkSkips" : 0,
        "millis" : 135,
        "indexBounds" : {
                "age" : [
                        [
                                {
                                        "$minElement" : 1
                                },
                                {
                                        "$maxElement" : 1
                                }
                        ]
                ]
        },
        "server" : "XCC-Duanshufeng:27017",
        "filterSet" : false
}


字段说明:
cursor:返回游标类型,有BasicCursor和BtreeCursor,BtreeCursor意味着使用了索引
nscanned:扫描document的行数
nscannedObjects:扫描对象的数量
n:返回的文档行数
millis:耗时(毫秒)
indexBounds:如果不为空,表示此查询使用的索引信息
server:MongoDB所在的服务器名字,27017是端口号


索引的限制:
索引名称不能超过128个字符
每个集合不能超过64个索引
复合索引不能超过31列

上述就是小编为大家分享的MongoDB中怎么查看执行计划方法了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。


本文题目:MongoDB中怎么查看执行计划方法
标题路径:http://cdkjz.cn/article/pgegsc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220