当前位置:网站首页>Mongodb query analyzer parsing
Mongodb query analyzer parsing
2022-08-05 06:13:00 【sick caterpillar】
Mongodb查询分析器
- Data volume and throughput interfaces are involved in dynamically related projects,For example, pay attention to page dynamics,附近动态,This part of the data is stored in mongodb中,Classify two in online datamongodb集合存储
- Among them, the focus is on the design of dynamic diffusion-based writing,The amount of data is almost here 8 亿.
- Nearby dynamic data expansion without write diffusion,And the exposure is a little less than the attention page,And importantly there isTTL,So near dynamically related table data50万以上
- Under the query of large data volume,Optimizing query speed is a key point to improve system performance,在Mysql中我们有explan 诊断工具,Come help us come rightsql进行分析,同样的MongodbOne of the diagnostic tools for getting information about queries in explain() 函数,在《MongoDB权威指南》(I only read the index chapter)书中解释:
explain会返回查询使用的索引情况(如果有的话),Statistics on time consumption and number of scanned documents......使用explainwill get the index used by the current query,消耗了多少时间,Already database how many documents need to be scanned to get results.
- But used in the bookMongodb应该是3.2 版本之前的,Because the given index analysis case is as follows:
{
"cursor" : "BtreeCursor gender_1_user_name_1",
"isMultiKey" : false,
"n" : 1,
"nscannedObjects" : 0,
"nscanned" : 1,
"nscannedObjectsAllPlans" : 0,
"nscannedAllPlans" : 1,
"scanAndOrder" : false,
"indexOnly" : true,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" : {
"gender" : [
[
"M",
"M"
]
],
"user_name" : [
[
{
"$minElement" : 1
},
{
"$maxElement" : 1
}
]
]
}
}
- We get completely different output in our own database:
//db.moment.explain(executionStats).find({"subscriberID" : NumberLong(1884831336), "type" : { "$in" : [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] } }).sort({"auditTime" : -1});
{
"queryPlanner": {
"mongosPlannerVersion": 1,
"winningPlan": {
"stage": "SINGLE_SHARD",
"shards": [{
"shardName": "cmgo-hgz5ixhj_0",
"connectionString": "cmgo-hgz5ixhj_0/100.120.151.75:7004,100.120.152.197:7000,100.93.47.81:7016",
"serverInfo": {
"host": "TENCENT64.site",
"port": 7016,
"version": "3.2.10-cmongo-",
"gitVersion": "nogitversion"
},
"plannerVersion": 1,
"namespace": "moment.moment",
"indexFilterSet": false,
"parsedQuery": {
"$and": [{
"subscriberID": {
"$eq": NumberLong(1884831336)
}
},
{
"type": {
"$in": [
1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
}
}]
},
"winningPlan": {
"stage": "SORT",
"sortPattern": {
"auditTime": -1
},
"inputStage": {
"stage": "SORT_KEY_GENERATOR",
"inputStage": {
"stage": "FETCH",
"filter": {
"type": {
"$in": [
1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
}
},
"inputStage": {
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"momentID": 1
},
"indexName": "idx_objectid_momentid",
"isMultiKey": false,
"isUnique": true,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "forward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"momentID": ["[MinKey, MaxKey]"]
}
}
}
}
},
"rejectedPlans": [{
"stage": "FETCH",
"inputStage": {
"stage": "SORT_MERGE",
"sortPattern": {
"auditTime": -1
},
"inputStages": [{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[19.0, 19.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[18.0, 18.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[17.0, 17.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[16.0, 16.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[15.0, 15.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[14.0, 14.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[13.0, 13.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[12.0, 12.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[11.0, 11.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[10.0, 10.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[8.0, 8.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[7.0, 7.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[6.0, 6.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[5.0, 5.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[4.0, 4.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[3.0, 3.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[2.0, 2.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
},
{
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"type": 1,
"auditTime": 1
},
"indexName": "subscriberID_1_type_1_auditTime_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "backward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"type": ["[1.0, 1.0]"],
"auditTime": ["[MaxKey, MinKey]"]
}
}]
}
},
{
"stage": "SORT",
"sortPattern": {
"auditTime": -1
},
"inputStage": {
"stage": "SORT_KEY_GENERATOR",
"inputStage": {
"stage": "FETCH",
"inputStage": {
"stage": "IXSCAN",
"keyPattern": {
"subscriberID": 1,
"unread": 1,
"type": 1
},
"indexName": "subscriberID_1_unread_1_type_1",
"isMultiKey": false,
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "forward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"unread": ["[MinKey, MaxKey]"],
"type": ["[1.0, 1.0]", "[2.0, 2.0]", "[3.0, 3.0]", "[4.0, 4.0]", "[5.0, 5.0]", "[6.0, 6.0]", "[7.0, 7.0]", "[8.0, 8.0]", "[10.0, 10.0]", "[11.0, 11.0]", "[12.0, 12.0]", "[13.0, 13.0]", "[14.0, 14.0]", "[15.0, 15.0]", "[16.0, 16.0]", "[17.0, 17.0]", "[18.0, 18.0]", "[19.0, 19.0]"]
}
}
}
}
}]
}]
}
},
"executionStats": {
"nReturned": 71,
"executionTimeMillis": 4,
"totalKeysExamined": 71,
"totalDocsExamined": 71,
"executionStages": {
"stage": "SINGLE_SHARD",
"nReturned": 71,
"executionTimeMillis": 4,
"totalKeysExamined": 71,
"totalDocsExamined": 71,
"totalChildMillis": NumberLong(2),
"shards": [{
"shardName": "cmgo-hgz5ixhj_0",
"executionSuccess": true,
"executionStages": {
"stage": "SORT",
"nReturned": 71,
"executionTimeMillisEstimate": 0,
"works": 146,
"advanced": 71,
"needTime": 73,
"needYield": 0,
"saveState": 3,
"restoreState": 3,
"isEOF": 1,
"invalidates": 0,
"sortPattern": {
"auditTime": -1
},
"memUsage": 13682,
"memLimit": 33554432,
"inputStage": {
"stage": "SORT_KEY_GENERATOR",
"nReturned": 0,
"executionTimeMillisEstimate": 0,
"works": 73,
"advanced": 0,
"needTime": 1,
"needYield": 0,
"saveState": 3,
"restoreState": 3,
"isEOF": 1,
"invalidates": 0,
"inputStage": {
"stage": "FETCH",
"filter": {
"type": {
"$in": [
1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
}
},
"nReturned": 71,
"executionTimeMillisEstimate": 0,
"works": 72,
"advanced": 71,
"needTime": 0,
"needYield": 0,
"saveState": 3,
"restoreState": 3,
"isEOF": 1,
"invalidates": 0,
"docsExamined": 71,
"alreadyHasObj": 0,
"inputStage": {
"stage": "IXSCAN",
"nReturned": 71,
"executionTimeMillisEstimate": 0,
"works": 72,
"advanced": 71,
"needTime": 0,
"needYield": 0,
"saveState": 3,
"restoreState": 3,
"isEOF": 1,
"invalidates": 0,
"keyPattern": {
"subscriberID": 1,
"momentID": 1
},
"indexName": "idx_objectid_momentid",
"isMultiKey": false,
"isUnique": true,
"isSparse": false,
"isPartial": false,
"indexVersion": 1,
"direction": "forward",
"indexBounds": {
"subscriberID": ["[1884831336, 1884831336]"],
"momentID": ["[MinKey, MaxKey]"]
},
"keysExamined": 71,
"dupsTested": 0,
"dupsDropped": 0,
"seenInvalidated": 0
}
}
}
}
}]
}
},
"ok": 1
}
I see the version of our test library is:3.4.21,Since it is different from the book,去官网看看吧,Anyway, the book is also the translation of the official website,Mongodb中explain()函数的网址,中文的Mongodb中explain() 网址
As found on the official website,在3.2After the version, the analysis of some functions is newly supported,And there is also a little change in the pre-launch rules
//之前
db.collection.<method(...)>.explain()
//现在
db.collection.explain().<method(...)>
并且在explain()The function also supports parameter selection of various modes of analysis,如下:
分为三种模式
- queryPlanner(默认模式)
- executionStats:Returns statistical information about the query process,Including use at will,The number of scanned documents has checked the processing time(毫秒计算)
- allPlansExecution:View some of the execution statistics collected during plan selection.
我们主要用的是excutionStatsmode for analysis,The longest one aboveexplain返回的json为例:
对queryPlanner分析
- queryPlanner : 标识queryPlanner的返回
- queryPlanner.namespace:该值返回的是该query所查询的表
- queryPlanner.indexFilterSet:针对该query是否有indexfilter
- queryPlanner.winningPlan:查询优化器针对该query所返回的最优执行计划的详细内容.
- queryPlanner.winningPlan.stage:最优执行计划的stage,这里返回是SORT,可以理解为通过返回的index位置去检索具体的文档,and sorted in memory(stage有多个模式,It will be explained later).
- queryPlanner.winningPlan.inputStage:用来描述子stage,并且为其父stage提供文档和索引关键字.
- queryPlanner.winningPlan.inputStage.stage: 此处是SORT_KEY_GENERATOR,I have been looking for this on the official website for a long time and only found oneissues,最后在stackoverflowFound the answer I needed on ,最关键的一句话: means in-memory sorting,sorted in memory
- queryPlanner.winningPlan.keyPattern:所扫描的index内容,此处是"subscriberID" : 1,“momentID” : 1
- queryPlanner.winningPlan.indexName:winning plan所选用的index.这里选用的idx_objectid_momentid 索引
- queryPlanner.winningPlan.isMultiKey是否是Multikey,此处返回是false,如果索引建立在array上,此处将是true.
- queryPlanner.winningPlan.direction:此query的查询顺序,此处是forward,It must be if the query order is the opposite of the set orderbackward,This section will be explained with a case below.
- queryPlanner.winningPlan.indexBounds:winningplan所扫描的索引范围,如果没有制定范围就是[MaxKey, MinKey],这主要是直接定位到mongodb的chunck中去查找数据,加快数据读取.(chunkRefers to a subset of data in a collection,在分片的时候,每个分区就是一个chunck)
- queryPlanner.rejectedPlans:其他执行计划(非最优而被查询优化器reject的)的详细返回,其中具体信息与winningPlan的返回中意义相同
对executionStatsIntermediate time analysis
- executionTimeMillis : Refers to our estimated execution time,越小越好,There are three of this time data,分别如下:
- 第一层, executionStats.executionTimeMillis: 该query的整体查询时间.
- 第二层,executionStats.executionStages.executionTimeMillisEstimate: 该查询根据index去检索document获得71条数据的时间.
- 第三层,executionStats.executionStages.inputStage.executionTimeMillisEstimate:此处没有,该查询扫描71行index所用时间.
- executionTimeMillis : Refers to our estimated execution time,越小越好,There are three of this time data,分别如下:
对executionStatsAnalysis of the number of scans in
- nReturned、totalKeysExamined、totalDocsExamined,Respectively represent the number of items returned by the query,索引扫描条数,文档扫描条数,这些都是直观地影响到executionTimeMillis,我们需要扫描的越少速度越快.
- corresponds to a query,理想状态下是 nReturned=totalKeysExamined=totalDocsExamined,That is, the data we need is found in the index data document
对stage状态分析
- stagetype will be affectedtotalKeysExamined和totalDocsExaminedthe final scan value
- COLLSCAN:全表扫描
- IXSCAN:索引扫描
- FETCH:根据索引去检索指定document
- SHARD_MERGE:将各个分片返回数据进行merge
- SORT:表明在内存中进行了排序
- SORT_KEY_GENERATOR : Table names are sorted in memory
- LIMIT:使用limit限制返回数
- SKIP:使用skip进行跳过
- IDHACK:针对_id进行查询
- SHARDING_FILTER:通过mongos对分片数据进行查询
- COUNT:利用db.coll.explain().count()之类进行count运算
- COUNTSCAN:count不使用Index进行count时的stage返回
- COUNT_SCAN:count使用了Index进行count时的stage返回
- SUBPLA:未使用到索引的$or查询的stage返回
- TEXT:使用全文索引进行查询时候的stage返回
- PROJECTION:限定返回字段时候stage的返回
- SINGLE_SHARD: Queries fall on a single shard query
What we expect in production is:
- Fetch+IDHACK
- Fetch+IXSCAN
- Limit+(Fetch+IXSCAN)
- PROJECTION+IXSCAN
- SINGLE_SHARD+IXSCAN
- COUNT_SCAN
不希望看到的:
- COLLSCAN,全表
- SORT,Sorting is used but the index is not hit,内存排序
- 不要用SKIPto do a skip operation
- SUBPLA,没有用到索引的or命令
- COUNTSCAN,没有用到索引的count
关于上面direction是backward的原因,有必要说明:
When we do not set the sorting field,Because the index of the walk isidx_objectid_momentid :{“subscriberID” : 1,“momentID” : 1},Both field indexes are created sequentially.As follows in the case of no specified sorting by default,momentID是顺序排列的.
If we force this statement to go subscriberID_1_type_1_auditTime_1 索引,那么他肯定是backround,Because the order in which you query is the opposite of the order in which your index was created:
//db.moment.explain("executionStats").find({"subscriberID" : NumberLong(1884831336), "type" : { "$in" : [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] } }).sort({"auditTime": -1}).hint({"subscriberID" : 1,"type" : 1,"auditTime" : 1});
{
"queryPlanner" : {
"mongosPlannerVersion" : 1,
"winningPlan" : {
"stage" : "SINGLE_SHARD",
"shards" : [
{
"shardName" : "cmgo-hgz5ixhj_0",
"connectionString" : "cmgo-hgz5ixhj_0/100.120.151.75:7004,100.120.152.197:7000,100.93.47.81:7016",
"serverInfo" : {
"host" : "TENCENT64.site",
"port" : 7016,
"version" : "3.2.10-cmongo-",
"gitVersion" : "nogitversion"
},
"plannerVersion" : 1,
"namespace" : "moment.moment",
"indexFilterSet" : false,
"parsedQuery" : {
"$and" : [
{
"subscriberID" : {
"$eq" : NumberLong(1884831336)
}
},
{
"type" : {
"$in" : [
1,
2,
3,
4,
5,
6,
7,
8,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
]
}
}
]
},
"winningPlan" : {
"stage" : "FETCH",
"inputStage" : {
"stage" : "SORT_MERGE",
"sortPattern" : {
"auditTime" : -1
},
"inputStages" : [
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[19.0, 19.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[18.0, 18.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[17.0, 17.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[16.0, 16.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[15.0, 15.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[14.0, 14.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[13.0, 13.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[12.0, 12.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[11.0, 11.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[10.0, 10.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[8.0, 8.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[7.0, 7.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[6.0, 6.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[5.0, 5.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[4.0, 4.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[3.0, 3.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[2.0, 2.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[1.0, 1.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
}
]
}
},
"rejectedPlans" : [ ]
}
]
}
},
"executionStats" : {
"nReturned" : 71,
"executionTimeMillis" : 3,
"totalKeysExamined" : 71,
"totalDocsExamined" : 71,
"executionStages" : {
"stage" : "SINGLE_SHARD",
"nReturned" : 71,
"executionTimeMillis" : 3,
"totalKeysExamined" : 71,
"totalDocsExamined" : 71,
"totalChildMillis" : NumberLong(1),
"shards" : [
{
"shardName" : "cmgo-hgz5ixhj_0",
"executionSuccess" : true,
"executionStages" : {
"stage" : "FETCH",
"nReturned" : 71,
"executionTimeMillisEstimate" : 0,
"works" : 161,
"advanced" : 71,
"needTime" : 89,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"docsExamined" : 71,
"alreadyHasObj" : 0,
"inputStage" : {
"stage" : "SORT_MERGE",
"nReturned" : 71,
"executionTimeMillisEstimate" : 0,
"works" : 160,
"advanced" : 71,
"needTime" : 89,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"sortPattern" : {
"auditTime" : -1
},
"dupsTested" : 71,
"dupsDropped" : 0,
"inputStages" : [
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[19.0, 19.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[18.0, 18.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[17.0, 17.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[16.0, 16.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[15.0, 15.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[14.0, 14.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[13.0, 13.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 6,
"executionTimeMillisEstimate" : 0,
"works" : 7,
"advanced" : 6,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[12.0, 12.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 6,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[11.0, 11.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[10.0, 10.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[8.0, 8.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[7.0, 7.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 0,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 0,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[6.0, 6.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 0,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 3,
"executionTimeMillisEstimate" : 0,
"works" : 4,
"advanced" : 3,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[5.0, 5.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 3,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 8,
"executionTimeMillisEstimate" : 0,
"works" : 9,
"advanced" : 8,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[4.0, 4.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 8,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 25,
"executionTimeMillisEstimate" : 0,
"works" : 26,
"advanced" : 25,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[3.0, 3.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 25,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 28,
"executionTimeMillisEstimate" : 0,
"works" : 29,
"advanced" : 28,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[2.0, 2.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 28,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
},
{
"stage" : "IXSCAN",
"nReturned" : 1,
"executionTimeMillisEstimate" : 0,
"works" : 2,
"advanced" : 1,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[1884831336, 1884831336]"
],
"type" : [
"[1.0, 1.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
},
"keysExamined" : 1,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
}
]
}
}
}
]
}
},
"ok" : 1
}
The above statement is also the second most used statement in our dynamic,When following the page to view the second page dynamic,会带上_id,这个时候我们用hint The order forced him to go subscriberID_1_type_1_auditTime_1 索引,At this point his query isFETCH + SORT_MERGE,其中SORT_MERGE Also sort in memory and merge to get the best result.
From the above analysis, the index should have room for optimization,For example I build the following index:
db.moment.createIndex({
"subscriberID" : 1,"type" : 1,"auditTime" : -1 })
- Looks like a perfect fit for our query:
db.moment.explain("executionStats").find({
"subscriberID" : NumberLong(2000103230), "type" : {
"$in" : [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] } }).sort({
"auditTime": -1});
//得到的执行结果:
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "moment.moment",
"indexFilterSet" : false,
"parsedQuery" : {
"$and" : [
{
"subscriberID" : {
"$eq" : NumberLong(2000103230)
}
},
{
"type" : {
"$in" : [
1,
2,
3,
4,
5,
6,
7,
8,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
]
}
}
]
},
"winningPlan" : {
"stage" : "SORT",
"sortPattern" : {
"auditTime" : -1
},
"inputStage" : {
"stage" : "SORT_KEY_GENERATOR",
"inputStage" : {
"stage" : "FETCH",
"filter" : {
"type" : {
"$in" : [
1,
2,
3,
4,
5,
6,
7,
8,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
]
}
},
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"unread" : 1
},
"indexName" : "subscriberID_1_unread_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"unread" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"unread" : [
"[MinKey, MaxKey]"
]
}
}
}
}
},
"rejectedPlans" : [
{
"stage" : "FETCH",
"inputStage" : {
"stage" : "SORT_MERGE",
"sortPattern" : {
"auditTime" : -1
},
"inputStages" : [
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[1.0, 1.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[2.0, 2.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[3.0, 3.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[4.0, 4.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[5.0, 5.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[6.0, 6.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[7.0, 7.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[8.0, 8.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[10.0, 10.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[11.0, 11.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[12.0, 12.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[13.0, 13.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[14.0, 14.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[15.0, 15.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[16.0, 16.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[17.0, 17.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[18.0, 18.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : -1
},
"indexName" : "subscriberID_1_type_1_auditTime_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[19.0, 19.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
}
]
}
},
{
"stage" : "SORT",
"sortPattern" : {
"auditTime" : -1
},
"inputStage" : {
"stage" : "SORT_KEY_GENERATOR",
"inputStage" : {
"stage" : "FETCH",
"filter" : {
"type" : {
"$in" : [
1,
2,
3,
4,
5,
6,
7,
8,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
]
}
},
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"momentID" : 1
},
"indexName" : "idx_objectid_momentid",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"momentID" : [ ]
},
"isUnique" : true,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"momentID" : [
"[MinKey, MaxKey]"
]
}
}
}
}
},
{
"stage" : "SORT",
"sortPattern" : {
"auditTime" : -1
},
"inputStage" : {
"stage" : "SORT_KEY_GENERATOR",
"inputStage" : {
"stage" : "FETCH",
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"unread" : 1,
"type" : 1
},
"indexName" : "subscriberID_1_unread_1_type_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"unread" : [ ],
"type" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"unread" : [
"[MinKey, MaxKey]"
],
"type" : [
"[1.0, 1.0]",
"[2.0, 2.0]",
"[3.0, 3.0]",
"[4.0, 4.0]",
"[5.0, 5.0]",
"[6.0, 6.0]",
"[7.0, 7.0]",
"[8.0, 8.0]",
"[10.0, 10.0]",
"[11.0, 11.0]",
"[12.0, 12.0]",
"[13.0, 13.0]",
"[14.0, 14.0]",
"[15.0, 15.0]",
"[16.0, 16.0]",
"[17.0, 17.0]",
"[18.0, 18.0]",
"[19.0, 19.0]"
]
}
}
}
}
},
{
"stage" : "FETCH",
"inputStage" : {
"stage" : "SORT_MERGE",
"sortPattern" : {
"auditTime" : -1
},
"inputStages" : [
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[19.0, 19.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[18.0, 18.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[17.0, 17.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[16.0, 16.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[15.0, 15.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[14.0, 14.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[13.0, 13.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[12.0, 12.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[11.0, 11.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[10.0, 10.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[8.0, 8.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[7.0, 7.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[6.0, 6.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[5.0, 5.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[4.0, 4.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[3.0, 3.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[2.0, 2.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
},
{
"stage" : "IXSCAN",
"keyPattern" : {
"subscriberID" : 1,
"type" : 1,
"auditTime" : 1
},
"indexName" : "subscriberID_1_type_1_auditTime_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"type" : [ ],
"auditTime" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"type" : [
"[1.0, 1.0]"
],
"auditTime" : [
"[MaxKey, MinKey]"
]
}
}
]
}
}
]
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 4,
"executionTimeMillis" : 1,
"totalKeysExamined" : 4,
"totalDocsExamined" : 4,
"executionStages" : {
"stage" : "SORT",
"nReturned" : 4,
"executionTimeMillisEstimate" : 0,
"works" : 12,
"advanced" : 4,
"needTime" : 6,
"needYield" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 1,
"invalidates" : 0,
"sortPattern" : {
"auditTime" : -1
},
"memUsage" : 764,
"memLimit" : 33554432,
"inputStage" : {
"stage" : "SORT_KEY_GENERATOR",
"nReturned" : 4,
"executionTimeMillisEstimate" : 0,
"works" : 6,
"advanced" : 4,
"needTime" : 1,
"needYield" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 1,
"invalidates" : 0,
"inputStage" : {
"stage" : "FETCH",
"filter" : {
"type" : {
"$in" : [
1,
2,
3,
4,
5,
6,
7,
8,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
]
}
},
"nReturned" : 4,
"executionTimeMillisEstimate" : 0,
"works" : 5,
"advanced" : 4,
"needTime" : 0,
"needYield" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 1,
"invalidates" : 0,
"docsExamined" : 4,
"alreadyHasObj" : 0,
"inputStage" : {
"stage" : "IXSCAN",
"nReturned" : 4,
"executionTimeMillisEstimate" : 0,
"works" : 5,
"advanced" : 4,
"needTime" : 0,
"needYield" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"subscriberID" : 1,
"unread" : 1
},
"indexName" : "subscriberID_1_unread_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"subscriberID" : [ ],
"unread" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"subscriberID" : [
"[2000103230, 2000103230]"
],
"unread" : [
"[MinKey, MaxKey]"
]
},
"keysExamined" : 4,
"seeks" : 1,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
}
}
}
}
},
"serverInfo" : {
"host" : "mongodb-0",
"port" : 27017,
"version" : "3.4.21",
"gitVersion" : "ba2e818de44c9a331ce09a624780a2bd841cf6e4"
},
"ok" : 1
}
- We see the result is still the same SORT + SORT_KEY_GENERATOR,Meaning we still need to sort in memory,The reason is when we build:{“subscriberID” : 1,“type” : 1,“auditTime” : -1 } 索引的时候,MongoDBWill it give me the index data organized as follows:
- 优先按subscriberID 的顺序,
- 然后 type顺序
- 最后才是 auditTime 的逆序,如下案例
mongos> db.moment.find({
"subscriberID" : NumberLong(1896740278), "type" : {
"$in" : [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] } });
{
"_id" : ObjectId("5fd09738fb1a7b001444e64b"), "type" : 1, "momentID" : NumberLong(257617647), "memberID" : NumberLong(1519251653), "subscriberID" : NumberLong(1896740278), "auditStatus" : 0, "unread" : true, "createTime" : ISODate("2020-12-09T09:21:59Z"), }
{
"_id" : ObjectId("60a3a82062c4680014c7dd21"), "type" : 1, "momentID" : NumberLong(405945302), "subscriberID" : NumberLong(1896740278), "unread" : true, "auditTime" : ISODate("2021-05-18T11:42:25Z"), "createTime" : ISODate("2021-05-18T11:28:11Z"), }
{
"_id" : ObjectId("60a65571d359c60014c6149c"), "type" : 1, "momentID" : NumberLong(406114684), "subscriberID" : NumberLong(1896740278), "unread" : true, "auditTime" : ISODate("2021-05-20T12:26:25Z"), "createTime" : ISODate("2021-05-20T12:10:39Z"), }
{
"_id" : ObjectId("60d3000178512e001443830f"), "type" : 1, "momentID" : NumberLong(408785569), "subscriberID" : NumberLong(1896740278), "unread" : true, "auditTime" : ISODate("2021-06-23T09:33:53Z"), "createTime" : ISODate("2021-06-23T09:26:52Z"), }
{
"_id" : ObjectId("60e6d944ccc7d000148edac2"), "type" : 1, "momentID" : NumberLong(409971805), "subscriberID" : NumberLong(1896740278), "unread" : true, "auditTime" : ISODate("2021-07-08T10:53:56Z"), "createTime" : ISODate("2021-07-08T10:45:38Z"), }
{
"_id" : ObjectId("60eb97d3f12ad4001491f83f"), "type" : 1, "momentID" : NumberLong(410215242), "subscriberID" : NumberLong(1896740278), "unread" : true, "auditTime" : ISODate("2021-07-12T01:16:03Z"), "createTime" : ISODate("2021-07-12T01:07:27Z"), }
{
"_id" : ObjectId("61016cc1b572ea001497550f"), "type" : 1, "momentID" : NumberLong(411549007), "subscriberID" : NumberLong(1896740278), "unread" : true, "auditTime" : ISODate("2021-07-28T14:42:09Z"), "createTime" : ISODate("2021-07-28T14:42:09Z"), }
可以看到在objectId相同的时候,他是按照momentID的顺序排列,但是auditTimeThe order is only in momentIDThe same time is the reverse order,In fact, according to the index, he is still out of order.So when we sort the time,It still needs to be sorted in memory.
Then we should create the index as below:
db.moment.createIndex({
"subscriberID" : 1,"auditTime" : -1 ,"type" : 1})
db.moment.createIndex({
"type" : 1,"auditTime" : -1,"subscriberID" : 1})
Because we are a sharded database,按照subscriberID分片,因此,The two indexes have the same effect.But if both are created,MongoDBwill give you the choice of the first one,排序优先
在我们项目中,There are two query statements in the query concern dynamic part,The first page of a query,The page data after a query,带有_id,占比如下:
total number of queries:2,007,778
- Number of queries for the second page and beyond:584258
- The percentage of queries on the second page28% 左右,That is, most of them are actually viewed on the first page,It seems that the index still has room for optimization.
边栏推荐
- 云游戏未来展望
- CIPU,对云计算产业有什么影响
- The problem of redirecting to the home page when visiting a new page in dsf5.0
- 正则表达式小示例--获取重复最多的字符及其数量
- Configuration of TensorFlow ObjecDetectionAPI under Anaconda3 of win10 system
- D39_欧拉角与四元数
- 入门文档05 使用cb()指示当前任务已完成
- spark source code-RPC communication mechanism
- Remembering my first CCF-A conference paper | After six rejections, my paper is finally accepted, yay!
- 静态路由
猜你喜欢
云游戏未来展望
[Day1] (Super detailed steps) Build a soft RAID disk array
dsf5.0新建页面访问时重定向到首页的问题
OpenCV3.0 is compatible with VS2010 and VS2013
交换机原理
VRRP原理及命令
[Day5] Soft and hard links File storage, deletion, directory management commands
spark算子-map vs mapPartitions算子
【机器学习】1单变量线性回归
Dsf5.0 bounced points determine not return a value
随机推荐
乘云科技受邀出席2022阿里云合作伙伴大会荣获“聚力行远奖”
正则表达式小实例--去掉字符串中间和两边的空格
ROS视频教程
IP数据包格式(ICMP协议与ARP协议)
D39_坐标转换
spark source code-RPC communication mechanism
入门文档07 分阶段输出
解决这三大问题,运维效率将超90%的医院
Servlet跳转到JSP页面,转发和重定向
入门文档04 一个任务依赖另外一个任务时,需要按顺序执行
The idea of commonly used shortcut key
D41_缓冲池
正则表达式小实例--验证邮箱地址
【Machine Learning】1 Univariate Linear Regression
Getting Started 04 When a task depends on another task, it needs to be executed in sequence
Contextual non-local alignment of full-scale representations
js动态获取屏幕宽高度
spark源码-任务提交流程之-3-ApplicationMaster
Wireshark抓包及常用过滤方法
vim的三种模式