Mongodb查询执行时间

我使用了下面的查询,这花费了我很多时间

查询

db.saleOrder.find({"currentStatus._id":"147"},{"_id":1}).limit(10).explain("executionStats")

ExecutionStats结果

{
    "queryPlanner" : {
        "plannerVersion" : 1,
        "namespace" : "db_erp_tube.saleOrder",
        "indexFilterSet" : false,
        "parsedQuery" : {
            "currentStatus._id" : {
                "$eq" : "147"
            }
        },
        "winningPlan" : {
            "stage" : "LIMIT",
            "limitAmount" : 10,
            "inputStage" : {
                "stage" : "PROJECTION",
                "transformBy" : {
                    "_id" : 1
                },
                "inputStage" : {
                    "stage" : "COLLSCAN",
                    "filter" : {
                        "currentStatus._id" : {
                            "$eq" : "147"
                        }
                    },
                    "direction" : "forward"
                }
            }
        },
        "rejectedPlans" : [ ]
    },
    "executionStats" : {
        "executionSuccess" : true,
        "nReturned" : 10,
        "executionTimeMillis" : 8673,
        "totalKeysExamined" : 0,
        "totalDocsExamined" : 3458482,
        "executionStages" : {
            "stage" : "LIMIT",
            "nReturned" : 10,
            "executionTimeMillisEstimate" : 8460,
            "works" : 3458484,
            "advanced" : 10,
            "needTime" : 3458473,
            "needYield" : 0,
            "saveState" : 27019,
            "restoreState" : 27019,
            "isEOF" : 1,
            "invalidates" : 0,
            "limitAmount" : 10,
            "inputStage" : {
                "stage" : "PROJECTION",
                "nReturned" : 10,
                "executionTimeMillisEstimate" : 8450,
                "works" : 3458483,
                "advanced" : 10,
                "needTime" : 3458473,
                "needYield" : 0,
                "saveState" : 27019,
                "restoreState" : 27019,
                "isEOF" : 0,
                "invalidates" : 0,
                "transformBy" : {
                    "_id" : 1
                },
                "inputStage" : {
                    "stage" : "COLLSCAN",
                    "filter" : {
                        "currentStatus._id" : {
                            "$eq" : "147"
                        }
                    },
                    "nReturned" : 10,
                    "executionTimeMillisEstimate" : 8400,
                    "works" : 3458483,
                    "advanced" : 10,
                    "needTime" : 3458473,
                    "needYield" : 0,
                    "saveState" : 27019,
                    "restoreState" : 27019,
                    "isEOF" : 0,
                    "invalidates" : 0,
                    "direction" : "forward",
                    "docsExamined" : 3458482
                }
            }
        }
    },
    "serverInfo" : {
        "host" : "172.16.109",
        "port" : 27017,
        "version" : "4.0.0",
        "gitVersion" : "3b07af3d4f471ae89e8186d33bbb1d5259597d51"
    },
    "ok" : 1,
    "operationTime" : Timestamp(1556365275, 114),
    "$clusterTime" : {
        "clusterTime" : Timestamp(1556365275, 114),
        "signature" : {
            "hash" : BinData(0,"ppu91nKmeiC//+UvdsEbjrBTDLU="),
            "keyId" : NumberLong("6633468944474701825")
        }
    }
}

转载请注明出处:http://www.yihangfood.com/article/20230328/1502907.html