I got this below log in the mongodb slow query log. I have mongodb version running 5.0 with 3 shards in PSS mode.
The query is running on the primary key and the total docuemnt size 800KB, in the below query i see time spent on locks is around 12 seconds.
How can i reduce this time.
{
“t”: {
“$date”: “2023-03-14T18:02:45.788+05:30”
},
“s”: “I”,
“c”: “WRITE”,
“id”: 51803,
“ctx”: “conn1830718”,
“msg”: “Slow query”,
“attr”: {
“type”: “update”,
“ns”: “db_name.XXXXXX”,
“command”: {
“q”: {
“uid”: 307126413
},
“u”: {
“$push”: {
“psfd”: {
“$each”: [{
“mid”: 5373,
“aid”: 1488,
“trid”: “89461-5373-307126413-1488-230313105553”,
“guid”: “f0aeafbe-a05b-4519-b2bd-277f383febce”,
“st”: “drop”,
“dt”: 230313105553,
“adw”: 2,
“ad”: 230313,
“at”: 105553
}],
“$slice”: -5000
}
}
},
“multi”: false,
“upsert”: false
},
“planSummary”: “IXSCAN { uid: 1 }”,
“keysExamined”: 1,
“docsExamined”: 1,
“nMatched”: 1,
“nModified”: 1,
“nUpserted”: 0,
“numYields”: 0,
“queryHash”: “B34121E2”,
“planCacheKey”: “CFF4BBD8”,
“locks”: {
“ParallelBatchWriterMode”: {
“acquireCount”: {
“r”: 320
}
},
“ReplicationStateTransition”: {
“acquireCount”: {
“w”: 333
}
},
“Global”: {
“acquireCount”: {
“r”: 12,
“w”: 320
}
},
“Database”: {
“acquireCount”: {
“w”: 320
}
},
“Collection”: {
“acquireCount”: {
“w”: 320
}
},
“Mutex”: {
“acquireCount”: {
“r”: 700
}
}
},
“flowControl”: {
“acquireCount”: 180,
“acquireWaitCount”: 13,
“timeAcquiringMicros”: 12288598
},
“storage”: {
“data”: {
“bytesRead”: 31243557,
“timeReadingMicros”: 64674
}
},
“remote”: “172.31.22.28:35548”,
“durationMillis”: 794
}
}