It's time to ditch Medium for good! 🌈⚡️

Introducing Devblog by Hashnode. Blog on your domain for FREE. Highly customizable and optimized for developers.

Learn more

Why are Mongoose (MongoDB ODM) lean queries faster than normal queries?

Write your answer…

The main reason is because the objects returned when using lean() are plain Javascript objects. On the other hand objects returned with a normal query have extra Mongoose magic attached to them, like save function, getters and setters and other things.

The performance gain is in the difference of a plain JSON object versus a Mongoose object with all the fancy things it has. See

You can take advantage of this, if the operation you are running is just to read data, then use lean, if you need extra Mongoose functionality to edit the object and then save it, then call a regular query.

Here is an interesting article about performance tweaks for mongoose

Reply to this…