Hi!
I see a similar question that was unanswered:
https://www.mongodb.com/community/forums/t/change-stream-causes-rise-in-the-scanned-objects-returned-metric/146414
I am receiving a “Scanned Objects / Returned has gone above 1000” that seems to be originating from the change streams. I did not used to receive those alerts, they started happening recently.
According to change streams indexing and performance:
Change streams cannot use indexes. MongoDB does not support creating indexes on the oplog collection.
So I would like to ask what is causing this and what’s an action I could take to avoid it.
Thanks!
MongoDB version: 6.0.23
Tier: M30 (with scaling down)
Query profiler log (obfuscated names):
{
"type": "command",
"ns": "<collection>",
"appName": "<app>",
"command": {
"aggregate": "<collection>",
"pipeline": [
{
"$changeStream": {
"fullDocument": "updateLookup",
"fullDocumentBeforeChange": "whenAvailable",
"resumeAfter": {
"_data": "826833B4E2000000022B022C0100296E5A1004B65DC44F3CD8445A91EEFD2662C1E11046645F69640064660215A6092125B5ED26A57F0004"
}
}
},
{
"$match": {
"operationType": {
"$in": [
"insert",
"update",
"replace",
"delete"
]
}
}
}
],
"cursor": {},
"lsid": {
"id": {
"$binary": {
"base64": "jY0x3pRrR727pqn5GqciQw==",
"subType": "04"
}
}
},
"$clusterTime": {
"clusterTime": {
"$timestamp": {
"t": 1748243391,
"i": 45
}
},
"signature": {
"hash": {
"$binary": {
"base64": "szNARDzm5gueuBpaX0wU5DEfbkQ=",
"subType": "00"
}
},
"keyId": 7466478117821874177
}
},
"$db": "<db>"
},
"planSummary": "COLLSCAN",
"planningTimeMicros": 1014,
"cursorid": 6114367631589341584,
"keysExamined": 0,
"docsExamined": 834661,
"numYields": 1170,
"nreturned": 0,
"queryHash": "40BB329B",
"queryFramework": "classic",
"reslen": 297,
"locks": {
"ParallelBatchWriterMode": {
"acquireCount": {
"r": 1
}
},
"FeatureCompatibilityVersion": {
"acquireCount": {
"r": 1177
}
},
"ReplicationStateTransition": {
"acquireCount": {
"w": 2
}
},
"Global": {
"acquireCount": {
"r": 1177
}
},
"Database": {
"acquireCount": {
"r": 2
}
},
"Collection": {
"acquireCount": {
"r": 2
}
},
"Mutex": {
"acquireCount": {
"r": 7
}
}
},
"readConcern": {
"level": "majority"
},
"writeConcern": {
"w": "majority",
"wtimeout": 0,
"provenance": "implicitDefault"
},
"storage": {
"data": {
"bytesRead": 210637668,
"timeReadingMicros": 4666481
}
},
"remote": "172.31.248.66:1247",
"protocol": "op_msg",
"durationMillis": 14378,
"v": "6.0.23",
"isTruncated": false
}
And here’s the stats:
