We are using a mongoDB replicaset and facing the issue about slow query. Actually if i run below query on terminal or Compass, query is very fast. But if the query comes from application, so slow.
I set profiling level to 1 and slowms=100 and i saw the query and query was so slow because missing index.
And i create a compound index, so our query got so fast like 150ms.
When I fill in the relevant blanks from the application and search, it keeps me waiting for at least 10 minutes.
db.historydata.find({“topic.sistemID”:2, “topic.header.MesajALan”: 177, “topic.header.MesajId”:1071, “timestamp”:{$lte: 1684334263}}).sort({-1}).limit(1)
Then I came across something like this in the logs.
“replanReason”:“cached plan was less efficient than expected: expected trial execution to take 2 works but it took at least 20 works”,“cursorExhausted”:true,
do you have any idea?
Thanks