Hi Sajit
There could be many different reason why a query can be slow. For example, if the cluster is busy, long query times would be expected. Another is if you perform the query against a secondary, where it will block reads during oplog apply operations.
You mentioned that “at other times” the query is fast. Is there a different load on the cluster, different time of day, etc. that you can observe?
You might want to investigate further using mongostat
and mongotop
to see if there’s any pattern.
If you’re still having issues, could you post more information:
db.collection.explain().find(...)
, whether this is through mongos
or not, example documents, etc.)mongod
and mongos
logsBest regards
Kevin