首页 > 解决方案 > Mongodb查询解释opterationTime的含义?

问题描述

我们想找出常规字符串比较与正则表达式比较之间的性能差异。需要关于“操作时间”的进一步理解/解释。

任何人都可以解释“操作时间”的含义吗?

"operationTime" : Timestamp(1573768915, 16291) // 需要 16.291 毫秒?"operationTime" : Timestamp(1573768904, 15024) // 需要 15.024 毫秒?

db.getCollection("customer").find({accountId: "abcdefg"}).explain()
{ 
    "queryPlanner" : {
        "plannerVersion" : 1.0, 
        "namespace" : "myserver.customer", 
        "indexFilterSet" : false, 
        "parsedQuery" : {
            "accountId" : {
                "$eq" : "abcdefg"
            }
        }, 
        "winningPlan" : {
            "stage" : "FETCH", 
            "inputStage" : {
                "stage" : "IXSCAN", 
                "indexName" : "accountId_partnerId", 
                "isMultiKey" : false, 
                "multiKeyPaths" : {
                }, 
                "isUnique" : true, 
                "isSparse" : false, 
                "isPartial" : true, 
                "indexVersion" : 2.0, 
                "direction" : "forward", 
                "indexBounds" : {
                    "accountId" : [
                        "[\"abcdefg\", \"abcdefg\"]"
                    ], 
                    "partnerId" : [
                        "[MinKey, MaxKey]"
                    ]
                }
            }
        }, 
    }, 
    "serverInfo" : {
        "host" : "mongodb-delta-02", 
        "port" : 27017.0, 
        "version" : "3.6.10", 
        "gitVersion" : "3e3ab85bfb98875af3bc6e74eeb945b0719f69c8"
    }, 
    "ok" : 1.0, 
    **"operationTime" : Timestamp(1573768915, 16291),**
    "$clusterTime" : {
        "clusterTime" : Timestamp(1573768915, 16291)
    }
}

db.getCollection("customer").find({accountId: /^abcdefg$/}).explain()
{ 
    "queryPlanner" : {
        "plannerVersion" : 1.0, 
        "namespace" : "myserver-customer", 
        "indexFilterSet" : false, 
        "parsedQuery" : {
            "accountId" : {
                "$regex" : "^abcdefg$"
            }
        }, 
        "winningPlan" : {
            "stage" : "FETCH", 
            "inputStage" : {
                "stage" : "IXSCAN", 
                "filter" : {
                    "accountId" : {
                        "$regex" : "^abcdefg$"
                    }
                },
                "indexName" : "accountId_partnerId", 
                "isMultiKey" : false, 
                "isUnique" : true, 
                "isSparse" : false, 
                "isPartial" : true, 
                "indexVersion" : 2.0, 
                "direction" : "forward", 
                "indexBounds" : {
                    "accountId" : [
                        "[\"abcdefg\", \"abcdef:\")", 
                        "[/^abcdefg$/, /^abcdefg$/]"
                    ], 
                    "partnerId" : [
                        "[MinKey, MaxKey]"
                    ]
                }
            }
        },
    }, 
    "serverInfo" : {
        "host" : "mongodb-delta-02", 
        "port" : 27017.0, 
        "version" : "3.6.10", 
        "gitVersion" : "3e3ab85bfb98875af3bc6e74eeb945b0719f69c8"
    }, 
    "ok" : 1.0, 
    **"operationTime" : Timestamp(1573768904, 15024),**
    "$clusterTime" : {
        "clusterTime" : Timestamp(1573768904, 15024)
    }
}```

标签: mongodbperformanceshellexplain

解决方案


请务必阅读回复部分。整个描述将帮助您理解“响应字段”。

https://docs.mongodb.com/manual/reference/method/db.runCommand/index.html#response


推荐阅读