Hi Team,
I need help with the following query that is causing a CPU usage of 30%. How can we reduce the cause of this issue in the future?
- How can we reduce the query time from
op_msg
23145 to 100?
What is the exact solution?
Explain output:
{
"type": "command",
"ns": "dba.student",
"command": {
"aggregate": "student",
"pipeline": [
{
"$match": {
"$and": [
{ "status": "Open" },
{
"DateTime": {
"$gte": { "$date": "2023-08-18T13:51:37.495Z" }
}
},
{
"DateTime": {
"$lt": { "$date": "2023-09-17T13:51:37.495Z" }
}
}
]
}
},
{
"$group": {
"_id": "$storeNumber",
"totalSlotCount": { "$sum": 1 },
"minSlotDate": { "$min": "$appDateTime" }
}
}
],
"cursor": {},
"allowDiskUse": false,
"$db": "dba",
"$clusterTime": {
"clusterTime": {
"$timestamp": { "t": 1692366695, "i": 6 }
},
"signature": {
"hash": {
"$binary": {
"base64": "x6qCTzYPFUl+HPaNJ1umPcrI0os=",
"subType": "00"
}
},
"keyId": 7215676178336580000
}
}
},
"planSummary": "IXSCAN { status: 1, DateTime: 1, reservedTime: 1 }",
"cursorid": 4735232936145454000,
"keysExamined": 4355310,
"docsExamined": 4355310,
"numYields": 4474,
"nreturned": 101,
"queryHash": "E2C2E097",
"planCacheKey": "6DD10207",
"reslen": 6200,
"protocol": "op_msg",
"durationMillis": 23145,
"v": "4.4.23"
}