Mongoose 6.3.6 Performance slowdown
See original GitHub issuePrerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the performance issue has not already been reported
Last performant version
6.3.5
Slowed down in version
6.3.6
Node.js version
16.14.2
🦥 Performance issue
Hello!
The latest version of mongoose which is 6.3.6 has significantly increased my bot’s start up time and increased memory usage, as you can see in this picture: (this picture shows how long it took to import a command.)
Meanwhile with 6.3.5, the results differ alot:
As you can see it slows down the bot significantly by around 1000~ ms!
Also here is how I connect to my MongoDB database:
import mongoose from "mongoose";
import { config } from "../../utils/config";
export async function database(): Promise<void> {
mongoose.connect
(
config.MONGODB_URI
)
.then(() => console.log(`[DATABASE] Connected to database.`))
.catch(err => console.log(`[DATABASE] Oops, there was an error! ${err}`));
}
Steps to Reproduce
Run a discord bot with mongoose installed as a npm package and make it connect to a MongoDB database.
Expected Behavior
Should not slow down the bot in any way.
Issue Analytics
- State:
- Created a year ago
- Comments:14
Top Results From Across the Web
Mongoose execution time increased 2 times after upgrading 4 ...
The issue first time the performance heavily broke down was with Commit d9c2a46 where mongooses upgraded mongodb native driver from 3.0.2 to 3.0 ......
Read more >Mongoose v6.8.2: API docs
Mongoose only emits a 'disconnected' event after a heartbeat has failed, so you may want to decrease this setting to reduce the time...
Read more >How to optimize MongoDB & Mongoose for Performance
1. Use lean queries for GET operations. This is probably the best thing you can do to improve the performance of a query....
Read more >Release Notes for MongoDB 3.6
12 - April 8, 2019. Issues fixed: SERVER-35219 : Regain MongoDB balancer performance with sessions.
Read more >mongoose - npm
Start using mongoose in your project by running `npm i mongoose`. ... Sometimes issues may arise when the local hostname has been changed....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hmmm, yes. It seems to have improved and is back to normal.
I didn’t notice the ts-node bit.
However, running the script in https://github.com/Automattic/mongoose/issues/11919#issuecomment-1152341631 calculates the time of the connection, which still demonstrates the issue, so this eliminates the possibility that this is a TS issue.
However, the issue is solved now, so I think we’re good.