Hi Everyone,
I have a simple api using the mongoose find method, along with an _id filter:
Fee.find(
{
_id: feeDocId,
},
(err, fee) => {
if (fee[0] !== undefined) {
if (!err && fee[0] != “”) {
res.json(fee[0][“gstno”]);
}
}
}
)
The problem is that the response time of this api keeps on increasing exponentially with time (high latency).
API call | Latency (response time) |
---|---|
First time | 68ms |
Third time | 22.75 sec |
Fifth time | 55.18 sec |
Seventh time | 1.6 minutes |
ninth time | 2.3 minutes |
fired at api 2022-05-11T12:45:03+05:30 {}
response at api{
explainVersion: '1',
queryPlanner: {
namespace: 'myFirstDatabase.fee',
indexFilterSet: false,
parsedQuery: { _id: [Object] },
maxIndexedOrSolutionsReached: false,
maxIndexedAndSolutionsReached: false,
maxScansToExplodeReached: false,
winningPlan: { stage: 'IDHACK' },
rejectedPlans: []
},
executionStats: {
executionSuccess: true,
nReturned: 1,
executionTimeMillis: 1,
totalKeysExamined: 1,
totalDocsExamined: 1,
executionStages: {
stage: 'IDHACK',
nReturned: 1,
executionTimeMillisEstimate: 0,
works: 2,
advanced: 1,
needTime: 0,
needYield: 0,
saveState: 0,
restoreState: 0,
isEOF: 1,
keysExamined: 1,
docsExamined: 1
},
allPlansExecution: []
},
command: {
find: 'fee',
filter: { _id: new ObjectId("623042ce5fc371ac74c9b371") },
projection: {},
'$db': 'myFirstDatabase'
},
}
response at api 2022-05-11T12:48:41+05:30
API took this much time 217829
Any ideas as to why the latency increases progressively? Thanks in advance…