Answer the question
In order to leave comments, you need to log in
Why is MongoDB slow?
There is such a problem, I came to a new project, and then a simple request to get 1500 records from the database takes 3.2 seconds (search without transmission). I can't find the reason. On older projects it worked much faster. Tell me what could be the reason.
Answer the question
In order to leave comments, you need to log in
I see mongoose in the tags. A couple of tips for working with it: try playing around with limiting fields through find().select(/* объект с полями */)
. By default, mongoose returns a collection of its wrappers over JS objects, which are quite heavy. You can get POJOs with find().lean()
. In order not to wait until the entire collection of 1500 records is returned to you, you can use stream cursors and work with these packs.
But it's really hard to say what the problem is here - the hardware is really not bad, but the problem is most likely in the IO cycle, as it usually happens, depending on the number of nodes between the client, server and database server. Maybe you have a proxy in front of the server and does not pull under load, maybe the server is overloaded with requests and you are waiting in the queue, maybe there are a lot of connections to the database and you, again, are waiting.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question