When there is where query applied on arguments and job_class query execution time is faster but Key Examined value (~40 k) is going very high as compared to Docs returned (0/1) even after index on ‘arguments’ column is used.
So what could be the case that even after index being used Key Examined values are high? and can this be the reason for CPU utilization spike up?
Hi @Viraj_Chheda and welcome to MongoDB community forums!!
If the keyExamined value is higher than docsReturned value, it means that more index entries were examined during the query execution than the number of matching documents found.
This may occur because of the following reasons:
When the indexes not have much distinct value which makes the query scan more documents the retuning the matching documents.
This would also depend on how the query has been written for it to make efficient use of the indexes.
For instance, I tried to replicate this in my local environment using version 6.0.5.
Sample data:
Hi @aasawari_sahasrabuddhe
I am also facing a similar issue in our production environment where we have for a query
“keysExamined”:1405142,“docsExamined”:1405142,“nreturned”:4
“fromMultiPlanner”:true,“cursorExhausted”:true,“numYields”:4902,
we saw this query read approximately → “bytesRead”:29890117105 and “durationMillis”:58425
The deployment architecture for us is replica set of 3 - 1 primary, 2 secondary
we are using version 6 for MongoDB
we have a compund index on Values.k_1_Values.v._v.v_1_ApplicationId_1_TrackingId_1
where Values is an Array and ApplicationId and TrackingId are string
This operation also appeared to be running at the time when we observed a spike in replication lag.
Any suggestions/recommendations here? We have created all the indexes the performance advisor in MongoDB atlas suggested