When I query through mongo shell or robo 3t the query takes about 3ms to 5ms. But the same query from my node(12.18.3) application which uses mongoose(5.5.10) it takes about 6000ms on average. Robo 3t returns 50 documents by default and mongo shell returns 20 I guess. Node application was returning 800 documents. So I made mongo shell return 800 documents by setting DBQuery.shellBatchSize = 300. This query still took very less time than 6000ms.
What am I missing here ?
Edit 1: It's a Simple Query. db.gateways.find({org_id:1}) I have an index on org_id. Each Document has about 450 fields and average document size is 6.5kb. Above query returns 800 documents.
db.gateways.find({ org_id: 1 }). When I used .explain('executionStats') in node it was relatively faster(76ms from 6000ms), maybe because it didn't return any documents..explain('executionStats')does execute the query, so I reckon the query is fine and delay is elsewhere. How big are these documents? And does robo3t actually display the documents after 5ms, or does it take it a few seconds to render? Try testing with the same return size and document size on all platforms:db.gateways.find({ org_id: 1 }, {_id: 0}).limit(10)