-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slower performance and higher cpu from Mongoose 4 to 5 with large schemas #10275
Comments
… for each path when initing doc Re: #10275
We found a way to shave 10-20% off of this script by being smarter about how we look up map paths: we had a loop that was O(n^2) in the number of paths in the schema when looking up map paths that we improved by only looking at actual map paths. Won't help if you have a schema with 100 paths that are all maps, but in this case it helps a decent amount. We'll need to do a little bit of work to make our |
… for each path when initing doc Re: #10275
…void extra overhead of splitting when hydrating documents Re: #10275
We tracked down the primary culprit for the extra overhead: #7104. |
…)` to avoid perf hit when running `$getAllSubdocs()` Re: #10275
184f10f should be enough to fix this modulo test failures. |
Do you want to request a feature or report a bug:
Bug
What is the current behavior?
When dealing with larger schemas and loading a large number of records Mongoose 5.x seems to be much slower than 4.x.
On my development machine, loading 10k documents using v4 takes approx 4.7 seconds and v5 takes approx 18 seconds to to load the same documents using the same script.
I've created a test project to see the issue including scripts to test under v4 and v5:
https://github.com/ant-fx/mongoose-performance-v4-v5
What is the expected behavior?
Version 5.x should be at least as fast as v4.x
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node:
v14.5.0
Mongoose v4:
4.13.21
Mongoose v5:
5.12.10
The text was updated successfully, but these errors were encountered: