db.holdings.find({ "user_key" : "eafjhjafaefaefe", "deleted_on" : null })
{
"op" : "query",
"ns" : "userdatabase.holdings",
"query" : {
"find" : "holdings",
"filter" : {
"user_key" : "eafjhjafaefaefe",
"deleted_on" : null
},
"projection" : {
},
"limit" : 1,
"batchSize" : 1,
"singleBatch" : true
},
"keysExamined" : 1,
"docsExamined" : 1,
"cursorExhausted" : true,
"keyUpdates" : 0,
"writeConflicts" : 0,
"numYield" : 0,
"locks" : {
"Global" : {
"acquireCount" : {
"r" : NumberLong(2)
},
"acquireWaitCount" : {
"r" : NumberLong(1)
},
"timeAcquiringMicros" : {
"r" : NumberLong(9189404)
}
},
"Database" : {
"acquireCount" : {
"r" : NumberLong(1)
}
},
"Collection" : {
"acquireCount" : {
"r" : NumberLong(1)
}
}
},
"nreturned" : 1,
"responseLength" : 661,
"protocol" : "op_query",
"millis" : 9191,
"execStats" : {
"stage" : "CACHED_PLAN",
"nReturned" : 1,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 1,
"needTime" : 0,
"needYield" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 1,
"invalidates" : 0,
"inputStage" : {
"stage" : "LIMIT",
"nReturned" : 1,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 1,
"needTime" : 0,
"needYield" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 1,
"invalidates" : 0,
"limitAmount" : 1,
"inputStage" : {
"stage" : "FETCH",
"filter" : {
"deleted_at" : {
"$eq" : null
}
},
"nReturned" : 1,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 1,
"needTime" : 0,
"needYield" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 0,
"invalidates" : 0,
"docsExamined" : 1,
"alreadyHasObj" : 0,
"inputStage" : {
"stage" : "IXSCAN",
"nReturned" : 1,
"executionTimeMillisEstimate" : 0,
"works" : 1,
"advanced" : 1,
"needTime" : 0,
"needYield" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 0,
"invalidates" : 0,
"keyPattern" : {
"user_key" : 1,
"deleted_on" : 1
},
"indexName" : "user_key_deleted_on",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "forward",
"indexBounds" : {
"user_key" : [
"[\"eafjhjafaefaefe\", \"eafjhjafaefaefe\"]"
],
"deleted_on" : [
"[null, null]"
]
},
"keysExamined" : 1,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
}
}
}
},
"ts" : ISODate("2016-11-24T13:07:40.552Z"),
"client" : "172.18.20.200",
"allUsers" : [
{
"user" : "abc",
"db" : "userdatabase"
}
],
"user" : "abc@userdatabase"
}
"executionTimeMillis" : 0,
"totalKeysExamined" : 1,
"totalDocsExamined" : 1
Update: The instance size is r3.xlarge( 4 CPU cores, 32GB RAM)
1. The wiredTiger cache size is set to default
2. Total data size is 4GB including 3 other databases on same instance.
3. With this memory size working set is expected to fit in memory
4. The total number of collections is 10079
5. Yes. The ulimits have been changed to meet large number of open files i.e 600,000
Hope this makes it clear
Hi
I think Rhys may be correct. The query seems to stall waiting for something. Can you provide more information:
mongod
log during this stall period?mongod
processes, etc.db.currentOp()
during the stall, if possibledb.stats()
db.collection.stats()
for affected collectionsdb.holdings.stats()
db.holdings.explain('executionStats').find({user_key:..., deleted_on: ...})
Please note that you can use mtools (particularly mplotqueries and mloginfo) to help diagnose slow query events using the mongod
logs.
Best regards,
Kevin
Hi Kevin,
Below are the more specific details:
- What is your MongoDB and your O/S version?
- What is your deployment topology (standalone, replica set, or sharded cluster)?
- Has the server been setup using the recommended settings in the Production Notes?
- Does this always happen with the same query, or do other queries exhibit the same stall as well?
- Is there anything in the
mongod
log during this stall period?
- You mentioned “Total indexes in this DB: 89098”. Is this the size of the index in Bytes, or the number of indexes? How did you get this number?
- Are there any other process running on the server, e.g. backup process, other
mongod
processes, etc.
- Could you post the output of:
db.currentOp()
during the stall, if possible
db.stats()
db.holdings.stats()
- The execution stats output of the query, e.g.
db.holdings.explain('executionStats').find({user_key:..., deleted_on: ...})
db.serverStatus()["wiredTiger"]["cache"];
Are "modified pages evicted" & "unmodified pages evicted" very high?
Hi
Since the issue is intermittent, it is difficult to pin down exactly the cause. Can you determine a pattern in the slow queries, e.g. time of day, number of queries, output of db.currentOp()
during period of slowness, etc. However, from the stats output you provided:
{
"db" : "userdatabase",
"collections" : 11767,
"objects" : 967227,
"avgObjSize" : 3109.8919633136793,
"dataSize" : 3007971474,
"storageSize" : 1379016704,
"numExtents" : 0,
"indexes" : 106844,
"indexSize" : 2024378368,
"ok" : 1
}
What is your use case in this deployment, i.e. why do you have such a large amount of collections and indexes? If you intermittently encounter some unexplainable slow queries, it may be that you are either hitting some kind of hardware limitation, you have a resource contention in the machine, there are other operations being done in the database, or other as yet unknown reason. Have you tried upgrading the instance type, or consider sharding? Also, please note that the latest version of MongoDB in the 3.2 series is 3.2.11.
Best regards,
Kevin
The pattern isn't always recurring. However, the the time for some bunch of slow queries is same.
Hi Kaushik
Out of curiosity what could the theory be if pages evicted and unmodified pages evicted are very high?
In short, there are two “pages evicted” metrics: “modified pages evicted” which comes from updates (insert/update) and “unmodified pages evicted” which comes from reads (find/aggregate, etc.). The numbers for both metrics could approximately show you the reads/writes workload that you have on your server. The cause of high values in both metrics could include (but not limited to):
Of course, the exact cause is very specific to your workload & deployment.
Best regards,
Kevin