Hi @MaBeuLux88,
I turned on the profiler and ran explain db.HLQ.state.explain("executionStats").update(...)
.
{ "op" : "update", "ns" : "dbname.HLQ.state", "command" : { "q" : { "hlq.sign" : "33333421035679142344444" }, "u" : { "$set" : { "hlq" : { "sign" : "33333421035679142344444", "sign_type" : 0, ... }, "multi" : false, "upsert" : false }, "keysExamined" : 1, "docsExamined" : 1, "nMatched" : 1, "nModified" : 1, "keysInserted" : 7, "keysDeleted" : 7, "numYield" : 1, "queryHash" : "7DA4FEF0", "planCacheKey" : "538C9C8D", "locks" : { "ParallelBatchWriterMode" : { "acquireCount" : { "r" : NumberLong(3) } }, "ReplicationStateTransition" : { "acquireCount" : { "w" : NumberLong(4) } }, "Global" : { "acquireCount" : { "r" : NumberLong(1), "w" : NumberLong(3) } }, "Database" : { "acquireCount" : { "w" : NumberLong(3) } }, "Collection" : { "acquireCount" : { "w" : NumberLong(3) } }, "Mutex" : { "acquireCount" : { "r" : NumberLong(2) } } }, "flowControl" : { "acquireCount" : NumberLong(17), "timeAcquiringMicros" : NumberLong(21) }, "storage" : { "data" : { "bytesRead" : NumberLong(489844), "bytesWritten" : NumberLong(672696), "timeReadingMicros" : NumberLong(15626), "timeWritingMicros" : NumberLong(13037) }, "timeWaitingMicros" : { "cache" : NumberLong(915655) } }, "millis" : 1402, "planSummary" : "IXSCAN { hlq.sign: 1 }", "execStats" : { "stage" : "UPDATE", "nReturned" : 0, "executionTimeMillisEstimate" : 70, "works" : 2, "advanced" : 0, "needTime" : 1, "needYield" : 0, "saveState" : 1, "restoreState" : 1, "isEOF" : 1, "nMatched" : 1, "nWouldModify" : 1, "wouldInsert" : false, "inputStage" : { "stage" : "FETCH", "nReturned" : 1, "executionTimeMillisEstimate" : 11, "works" : 1, "advanced" : 1, "needTime" : 0, "needYield" : 0, "saveState" : 2, "restoreState" : 2, "isEOF" : 0, "docsExamined" : 1, "alreadyHasObj" : 0, "inputStage" : { "stage" : "IXSCAN", "nReturned" : 1, "executionTimeMillisEstimate" : 11, "works" : 1, "advanced" : 1, "needTime" : 0, "needYield" : 0, "saveState" : 2, "restoreState" : 2, "isEOF" : 0, "keyPattern" : { "hlq.sign" : 1 }, "indexName" : "hlq.sign_1", "isMultiKey" : false, "multiKeyPaths" : { "hlq.sign" : [ ] }, "isUnique" : false, "isSparse" : false, "isPartial" : false, "indexVersion" : 2, "direction" : "forward", "indexBounds" : { "hlq.sign" : [ "[\"33333421035679142344444\", \"33333421035679142344444\"]" ] }, "keysExamined" : 1, "seeks" : 1, "dupsTested" : 0, "dupsDropped" : 0 } } }, "ts" : ISODate("2021-02-01T11:29:51.591Z"), "client" : "10.0.0.146", "allUsers" : [ ], "user" : "" }
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "dbname.HLQ.state",
"indexFilterSet" : false,
"parsedQuery" : {
"hlq.sign" : {
"$eq" : "33333421035679142344444"
}
},
"winningPlan" : {
"stage" : "UPDATE",
"inputStage" : {
"stage" : "FETCH",
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"hlq.sign" : 1
},
"indexName" : "hlq.sign_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"hlq.sign" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"hlq.sign" : [
"[\"33333421035679142344444\", \"33333421035679142344444\"]"
]
}
}
}
},
"rejectedPlans" : [ ]
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 0,
"executionTimeMillis" : 55,
"totalKeysExamined" : 1,
"totalDocsExamined" : 1,
"executionStages" : {
"stage" : "UPDATE",
"nReturned" : 0,
"executionTimeMillisEstimate" : 1,
"works" : 2,
"advanced" : 0,
"needTime" : 1,
"needYield" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 1,
"nMatched" : 1,
"nWouldModify" : 1,
"wouldInsert" : false,
"inputStage" : {
"stage" : "FETCH",
"nReturned" : 1,
"executionTimeMillisEstimate" : 1,
"works" : 1,
"advanced" : 1,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 0,
"docsExamined" : 1,
"alreadyHasObj" : 0,
"inputStage" : {
"stage" : "IXSCAN",
"nReturned" : 1,
"executionTimeMillisEstimate" : 1,
"works" : 1,
"advanced" : 1,
"needTime" : 0,
"needYield" : 0,
"saveState" : 1,
"restoreState" : 1,
"isEOF" : 0,
"keyPattern" : {
"hlq.sign" : 1
},
"indexName" : "hlq.sign_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"hlq.sign" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"hlq.sign" : [
"[\"33333421035679142344444\", \"33333421035679142344444\"]"
]
},
"keysExamined" : 1,
"seeks" : 1,
"dupsTested" : 0,
"dupsDropped" : 0
}
}
}
},
"serverInfo" : {
"host" : "mongo01",
"port" : 27017,
"version" : "4.4.2",
"gitVersion" : "15e73dc5738d2278b688f8929aee605fe4279b0e"
},
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1612202001, 2215),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
},
"operationTime" : Timestamp(1612202001, 2121)
}
The request completed quickly. He has a good access plan.
We have a queue of write queries:
mongostat
insert query update delete getmore command dirty used flushes vsize res qrw arw net_in net_out conn set repl time
112 10089 2353 5 383 2303|0 20.8% 85.1% 0 283G 197G 0|786 61|128 7.41m 78.7m 16276 xxxxxx PRI Feb 1 16:00:04.057
Top queries:
{ "op" : "insert", "command" : { }, "millis" : 133940, "client" : "10.0.0.77" }
{ "op" : "insert", "command" : { }, "millis" : 96181, "client" : "10.0.0.76" }
{ "op" : "insert", "command" : { }, "millis" : 73975, "client" : "10.0.0.76" }
{ "op" : "insert", "command" : { }, "millis" : 62515, "client" : "10.0.0.77" }
{ "op" : "insert", "command" : { }, "millis" : 61380, "client" : "10.0.0.76" }
{ "op" : "insert", "command" : { }, "millis" : 55350, "client" : "10.0.0.77" }
{ "op" : "insert", "command" : { }, "millis" : 52383, "client" : "10.0.0.77" }
{ "op" : "insert", "command" : { }, "millis" : 48277, "client" : "10.0.0.78" }
{ "op" : "insert", "command" : { }, "millis" : 47941, "client" : "10.0.0.76" }
{ "op" : "insert", "command" : { }, "millis" : 47846, "client" : "10.0.0.76" }
{ "op" : "insert", "command" : { }, "millis" : 47621, "client" : "10.0.0.77" }
{ "op" : "insert", "command" : { }, "millis" : 45234, "client" : "10.0.0.76" }
{ "op" : "insert", "command" : { }, "millis" : 43663, "client" : "10.0.0.78" }
{ "op" : "insert", "command" : { }, "millis" : 39867, "client" : "10.0.0.78" }
{ "op" : "insert", "command" : { }, "millis" : 39616, "client" : "10.0.0.78" }
{ "op" : "insert", "command" : { }, "millis" : 36962, "client" : "10.0.0.77" }
{ "op" : "insert", "command" : { }, "millis" : 36874, "client" : "10.0.0.77" }
{ "op" : "insert", "command" : { }, "millis" : 23735, "client" : "10.0.0.76" }
{ "op" : "update", "command" : { }, "millis" : 1784, "client" : "10.0.0.152" }
{ "op" : "update", "command" : { }, "millis" : 1739, "client" : "10.0.0.126" }
{ "op" : "update", "command" : { }, "millis" : 1714, "client" : "10.0.0.77" }
{ "op" : "update", "command" : { }, "millis" : 1687, "client" : "10.0.0.125" }
{ "op" : "insert", "command" : { }, "millis" : 1659, "client" : "10.0.0.127" }
{ "op" : "update", "command" : { }, "millis" : 1637, "client" : "10.0.0.116" }
{ "op" : "update", "command" : { }, "millis" : 1623, "client" : "10.0.0.78" }
{ "op" : "update", "command" : { }, "millis" : 1614, "client" : "10.0.0.151" }
{ "op" : "update", "command" : { }, "millis" : 1611, "client" : "10.0.0.150" }
{ "op" : "update", "command" : { }, "millis" : 1556, "client" : "10.0.0.76" }
{ "op" : "insert", "command" : { }, "millis" : 1527, "client" : "10.0.0.146" }
{ "op" : "update", "command" : { }, "millis" : 1523, "client" : "10.0.0.114" }
{ "op" : "update", "command" : { }, "millis" : 1508, "client" : "10.0.0.144" }
{ "op" : "update", "command" : { }, "millis" : 1500, "client" : "10.0.0.125" }
{ "op" : "update", "command" : { }, "millis" : 1472, "client" : "10.0.0.109" }
many updates
We also have a lot of global locks and no write tickets available.
Can insert prevent update, or vice versa?
Best regards,
Konstantin