乱读天书, 不求甚解
周祎骏的个人云笔记
Toggle navigation
乱读天书, 不求甚解
主页
Linux:系统配置
Linux:用户管理
Linux:优化排错
Linux:进程调度
Linux:文件系统
Linux:网络
Linux:系统服务
Linux:安全
Linux:内核
容器:Docker
容器:containerd
容器编排:Kubernetes
IAC:Terraform
大数据:Hadoop
大数据:Zookeeper
大数据:Hbase
消息队列:rsyslog
消息队列:kafka
数据库:MySQL
数据库:MongoDB
搜索引擎:Elasticsearch
时序数据库:OpenTSDB
网站服务:Nginx
编程:Bash
编程:Perl
编程:Python
编程:C
编程:JAVA
编程:Rust
版本控制:gitlab
知识管理:docusaurus
常用小工具
关于我
标签
Mongodb 1.60 explain
2017-09-08 13:18:44
66
0
0
admin
> 通过explain 来分析query 3.0开始mongodb 的 explain有三种模式 * queryPlanner 默认方式,不会执行query,只是分析query然后选出一个query方式(winningPlan,通常mongo可能会有多种不同的query方式) * executionStats 执行query,会有更多信息 * allPlansExecution 执行所有query计划,更多更多信息 ``` > db.a.find({"a":2}).limit(1).explain("allPlansExecution") { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "abc.a", //查询的表 "indexFilterSet" : false, //是否有indexfilter //indexfilter决定对于某一类查询如何使用index "parsedQuery" : { "a" : { "$eq" : 2 } }, "winningPlan" : { //选出的最优的 "stage" : "LIMIT", //有以下可能 /* COLLSCAN =>全表扫描 IXSCAN=>索引扫描 FETCH=>根据索引去检索 SHARD_MERGE=>将各个分片返回结果进行merge SORT=>在内存中进行了排序 LIMIT=>用limit限制返回数 SKIP=>用skip进行跳过 IDHACK=>针对_id进行查询 SHARDING_FILTER=>通过mongos对分片数据进行查询 COUNT=>进行count运算 COUNTSCAN=>使用index进行count运算 PROJECTION=>只返回限定字段 TEXT=>使用全文索引进行查询 */ "limitAmount" : 1, "inputStage" : { // 迭代的stage "stage" : "COLLSCAN", "filter" : { "a" : { "$eq" : 2 } }, "direction" : "forward" } }, "rejectedPlans" : [ ] }, "executionStats" : { "executionSuccess" : true, //是否执行成功 "nReturned" : 1, //返回数据条数 "executionTimeMillis" : 0, //执行时间 "totalKeysExamined" : 0, //索引扫描次数 "totalDocsExamined" : 2, //文档扫描次数 "executionStages" : { "stage" : "LIMIT", "nReturned" : 1, "executionTimeMillisEstimate" : 0, "works" : 4, "advanced" : 1, "needTime" : 2, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "limitAmount" : 1, "inputStage" : { "stage" : "COLLSCAN", "filter" : { "a" : { "$eq" : 2 } }, "nReturned" : 1, "executionTimeMillisEstimate" : 0, "works" : 3, "advanced" : 1, "needTime" : 2, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "direction" : "forward", "docsExamined" : 2 } }, "allPlansExecution" : [ ] }, "serverInfo" : { "host" : "test1", "port" : 27017, "version" : "3.4.4", "gitVersion" : "888390515874a9debd1b6c5d36559ca86b44babd" }, "ok" : 1 } ```
上一篇:
Mongodb 1.50 Index
下一篇:
Mongodb 1.70 aggregation
文档导航