Home > front end >  MongoDB getMore taking up to 1s on UNKNOWN query shown on MongoDB compass
MongoDB getMore taking up to 1s on UNKNOWN query shown on MongoDB compass

Time:10-20

i was checking query performance with MongoDB compass and i noticed that there is a query taking up to 1s.

I tried to find out the query and don't know about what it is.

Time : 948.44 ms

Info

{
    "type": "op",
    "host": "Ubuntu-2004-focal-64-minimal",
    "desc": "conn479199",
    "connectionId": 479199,
    "client": "xxx",
    "clientMetadata": {
        "driver": {
            "name": "nodejs|Mongoose",
            "version": "4.9.1"
        },
        "os": {
            "type": "Windows_NT",
            "name": "win32",
            "architecture": "x64",
            "version": "10.0.22000"
        },
        "platform": "Node.js v18.9.1, LE (unified)",
        "version": "4.9.1|6.6.1"
    },
    "active": "true",
    "currentOpTime": "2022-10-19T12:26:14.835 02:00",
    "effectiveUsers": [
        {
            "user": "xxx",
            "db": "xxx"
        }
    ],
    "threaded": true,
    "opid": 367483579,
    "lsid": {
        "id": "mpMmCEyrQMiAAVagou2NCQ==",
        "uid": "97nSh3DQLZ6SIrtU91vZtdqotiM2qojisDAzHK9Mb6s="
    },
    "secs_running": 0,
    "microsecs_running": 948442,
    "op": "getmore",
    "ns": "snipe.xxx",
    "command": {
        "getMore": {
            "low": 1131828049,
            "high": 1183930404,
            "unsigned": false
        },
        "collection": "xxx",
        "batchSize": 1000,
        "lsid": {
            "id": "mpMmCEyrQMiAAVagou2NCQ=="
        },
        "$clusterTime": {
            "clusterTime": {
                "$timestamp": "7156167877442142275"
            },
            "signature": {
                "hash": "q/oCXN42KcLFMR9Wy/WNzNaNfMg=",
                "keyId": {
                    "low": 6,
                    "high": 1663608001,
                    "unsigned": false
                }
            }
        },
        "$db": "xxx"
    },
    "planSummary": "COLLSCAN",
    "cursor": {
        "cursorId": {
            "low": 1131828049,
            "high": 1183930404,
            "unsigned": false
        },
        "createdDate": "2022-10-19T10:07:08.178Z",
        "lastAccessDate": "2022-10-19T10:26:13.824Z",
        "nDocsReturned": 1385,
        "nBatchesReturned": 1820,
        "noCursorTimeout": false,
        "tailable": true,
        "awaitData": true,
        "originatingCommand": {
            "aggregate": "xxx",
            "pipeline": [
                {
                    "$changeStream": {}
                }
            ],
            "cursor": {},
            "lsid": {
                "id": "mpMmCEyrQMiAAVagou2NCQ=="
            },
            "$clusterTime": {
                "clusterTime": {
                    "$timestamp": "7156162955409621007"
                },
                "signature": {
                    "hash": "rnVbZaTEDLib0ozeNTSczKqchGk=",
                    "keyId": {
                        "low": 6,
                        "high": 1663608001,
                        "unsigned": false
                    }
                }
            },
            "$db": "xxx"
        },
        "operationUsingCursorId": 367483579
    },
    "numYields": 6,
    "locks": {},
    "waitingForLock": "false",
    "lockStats": {
        "FeatureCompatibilityVersion": {
            "acquireCount": {
                "r": 6
            }
        },
        "Global": {
            "acquireCount": {
                "r": 6
            }
        },
        "Mutex": {
            "acquireCount": {
                "r": 1
            }
        }
    },
    "waitingForFlowControl": false,
    "flowControlStats": {}
}

The main query should be where there is command etc (i guess).

Anyone can explain me what is this query about ?

Thanks

CodePudding user response:

The part of the output that tells us the answer to your question is the following:

        "originatingCommand": {
            "aggregate": "xxx",
            "pipeline": [
                {
                    "$changeStream": {}
                }
            ]

Therefore this getMore is associated with a Change Stream operation. The Change Stream functionality helps applications monitor changes on the database. This is coming from the application directly according to the following (as opposed to some internal operation for the database):

    "connectionId": 479199,
    "client": "xxx",
    "clientMetadata": {
        "driver": {
            "name": "nodejs|Mongoose",
            "version": "4.9.1"
        },

The fact that it is taking 1 second is not always a problem. Change streams usually wait for new data to become available before returning to the client.

  • Related