使用explain(" executionStats")查找查询的碎片数量?

时间:2018-02-25 23:50:29

标签: mongodb

我正在尝试使用.explain( "executionStats" )来查找在查询查询中查询了多少个分片以及检查了多少个文档。第二个很简单,找到"totalDocsExamined" :并完成了,但我不知道该找什么来查找查询了多少个分片。

我应该寻找什么来确定查询了多少个分片?

修改输入:

db.collection.find( { ... } ).limit( 5 ).explain( "executionStats" )

输出:

{
        "queryPlanner" : {
                "plannerVersion" : 1,
                "namespace" : "collection",
                "indexFilterSet" : false,
                "parsedQuery" : {
                        "$and" : [
                                {
                                        "field1" : {
                                                "$eq" : "T"
                                        }
                                },
                                {
                                        "field2" : {
                                                "$eq" : "A"
                                        }
                                }
                        ]
                },
                "winningPlan" : {
                        "stage" : "LIMIT",
                        "limitAmount" : 5,
                        "inputStage" : {
                                "stage" : "FETCH",
                                "inputStage" : {
                                        "stage" : "IXSCAN",
                                        "keyPattern" : {
                                                "field1" : 1,
                                                "field2" : 1
                                        },
                                        "indexName" : "indexName",
                                        "isMultiKey" : false,
                                        "multiKeyPaths" : {
                                                "field1" : [ ],
                                                "field2" : [ ]
                                        },
                                        "isUnique" : false,
                                        "isSparse" : false,
                                        "isPartial" : false,
                                        "indexVersion" : 2,
                                        "direction" : "forward",
                                        "indexBounds" : {
                                                "field1" : [
                                                        "[\"T\", \"T\"]"
                                                ],
                                                "field2" : [
                                                        "[\"A\", \"A\"]"
                                                ]
                                        }
                                }
                        }
                },
                "rejectedPlans" : [ ]
        },
        "executionStats" : {
                "executionSuccess" : true,
                "nReturned" : 5,
                "executionTimeMillis" : 15,
                "totalKeysExamined" : 5,
                "totalDocsExamined" : 5,
                "executionStages" : {
                        "stage" : "LIMIT",
                        "nReturned" : 5,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 6,
                        "advanced" : 5,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 0,
                        "restoreState" : 0,
                        "isEOF" : 1,
                        "invalidates" : 0,
                        "limitAmount" : 5,
                        "inputStage" : {
                                "stage" : "FETCH",
                                "nReturned" : 5,
                                "executionTimeMillisEstimate" : 0,
                                "works" : 5,
                                "advanced" : 5,
                                "needTime" : 0,
                                "needYield" : 0,
                                "saveState" : 0,
                                "restoreState" : 0,
                                "isEOF" : 0,
                                "invalidates" : 0,
                                "docsExamined" : 5,
                                "alreadyHasObj" : 0,
                                "inputStage" : {
                                        "stage" : "IXSCAN",
                                        "nReturned" : 5,
                                        "executionTimeMillisEstimate" : 0,
                                        "works" : 5,
                                        "advanced" : 5,
                                        "needTime" : 0,
                                        "needYield" : 0,
                                        "saveState" : 0,
                                        "restoreState" : 0,
                                        "isEOF" : 0,
                                        "invalidates" : 0,
                                        "keyPattern" : {
                                                "field1" : 1,
                                                "field2" : 1
                                        },
                                        "indexName" : "indexName",
                                        "isMultiKey" : false,
                                        "multiKeyPaths" : {
                                                "field1" : [ ],
                                                "field2" : [ ]
                                        },
                                        "isUnique" : false,
                                        "isSparse" : false,
                                        "isPartial" : false,
                                        "indexVersion" : 2,
                                        "direction" : "forward",
                                        "indexBounds" : {
                                                "field1" : [
                                                        "[\"T\", \"T\"]"
                                                ],
                                                "field2" : [
                                                        "[\"A\", \"A\"]"
                                                ]
                                        },
                                        "keysExamined" : 5,
                                        "seeks" : 1,
                                        "dupsTested" : 0,
                                        "dupsDropped" : 0,
                                        "seenInvalidated" : 0
                                }
                        }
                }
        },
        "serverInfo" : {
                "host" : "MSI",
                "port" : 27501,
                "version" : "3.6.2",
                "gitVersion" : "578d186dbd0f0320a7ca04d39fd78d0a2c659350"
        },
        "ok" : 1
}

其他请求信息:

MongoDB Enterprise > version()
3.6.2

MongoDB Enterprise > db.collection.getShardDistribution()
Collection collection is not sharded.

0 个答案:

没有答案