Skip to content

Why are there so many slow GETMORE operations? #756

@llk2yq

Description

@llk2yq

First, thanks for your work~

Here is my config:

monstache.toml:

[[mapping]]
namespace = "db.good"
index = "good"

[[mapping]]
namespace = "db.goodview"
index = "good"

[[relate]]
namespace = "db.good"
with-namespace = "db.goodview"
keep-src = false

[[relate]]
namespace = "db.book"
with-namespace = "db.good"
src-field = "_id"
match-field = "book"
keep-src = false

mongodb log:

{
    "type": "op",
    "host": "my-server:27017",
    "desc": "conn3074214",
    "connectionId": 3074214,
    "client": "10.0.0.4:46574",
    "appName": "monstache",
    "clientMetadata": {
        "application": {
            "name": "monstache"
        },
        "driver": {
            "name": "mongo-go-driver",
            "version": "1.17.2"
        },
        "os": {
            "type": "linux",
            "architecture": "amd64"
        },
        "platform": "go1.23.6"
    },
    "active": "true",
    "currentOpTime": "2025-10-12T13:08:13.179+08:00",
    "effectiveUsers": [
        {
            "user": "pub",
            "db": "dev"
        }
    ],
    "isFromUserConnection": true,
    "threaded": true,
    "opid": -873179958,
    "lsid": {
        "id": "73fd300e-bdde-4a1d-9b0b-a03a0138a0d2",
        "uid": "nVbog0YYoqNxjM6xiBTcVaYasFZhGBl7ILdtGLH/IEQ="
    },
    "secs_running": 33,  // very slow
    "microsecs_running": 33396393,
    "op": "getmore",
    "ns": "db.goodview",
    "redacted": false,
    "command": {
        "getMore": {
            "low": -1512137024,
            "high": 640742422,
            "unsigned": false
        },
        "collection": "goodview",
        "lsid": {
            "id": "73fd300e-bdde-4a1d-9b0b-a03a0138a0d2"
        },
        "$clusterTime": {
            "clusterTime": {
                "$timestamp": "7560197538330968081"
            },
            "signature": {
                "hash": "4RKigA4L9enGvuqfbwzDirjwYHQ=",
                "keyId": {
                    "low": 47,
                    "high": 1750362083,
                    "unsigned": false
                }
            }
        },
        "$db": "db"
    },
    "queryFramework": "classic",
    "planSummary": "COLLSCAN",
    "cursor": {
        "cursorId": {
            "low": -1512137024,
            "high": 640742422,
            "unsigned": false
        },
        "createdDate": "2025-10-12T05:01:37.817Z",
        "lastAccessDate": "2025-10-12T05:07:28.376Z",
        "nDocsReturned": 861839,
        "nBatchesReturned": 8,
        "noCursorTimeout": false,
        "tailable": false,
        "awaitData": false,
        "originatingCommand": {
            "aggregate": "good",
            "pipeline": [
                {
                    "$lookup": {
                        "from": "book",
                        "localField": "book",
                        "foreignField": "_id",
                        "as": "book_obj"
                    }
                },
                {
                    "$unwind": {
                        "path": "$book_obj",
                        "preserveNullAndEmptyArrays": true
                    }
                },
                {
                    "$project": {
                        "book": 1,
                        "book_obj": 1,
                        "stock": 1,
                        "_id": 1
                    }
                }
            ],
            "cursor": {
                "batchSize": 101
            },
            "collation": {
                "locale": "simple"
            },
            "querySettings": {}
        },
        "operationUsingCursorId": 3421787338
    },
    "numYields": 1094,
    "queues": {
        "ingress": {
            "admissions": 1,
            "totalTimeQueuedMicros": 0
        },
        "execution": {
            "admissions": 78846,
            "totalTimeQueuedMicros": 361532
        }
    },
    "currentQueue": null,
    "locks": {
        "Global": "r"
    },
    "waitingForLock": "false",
    "lockStats": {
        "Global": {
            "acquireCount": {
                "r": 78846
            }
        }
    },
    "waitingForFlowControl": false,
    "flowControlStats": {}
}

db.good has 2200000 docs, and db.book has 3200000 docs;

Why are there so many slow GETMORE operations? And how to optimize it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions