Discussion MongoDB

Improve querying speed in MongoDB

DB query speed is slowed down mainly when converting fetched data to MongoDB model format.
For example we fetch JSON format data from db and convert it to MongoDB model format by embedding model methods.
In order to avoid this and improve querying speed we can use lean function.
The format is model.find({…}).lean(), then the result is retrieved as JSON instead of model.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *