question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mongoose 6.3.6 Performance slowdown

See original GitHub issue

Prerequisites

  • 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: image (this picture shows how long it took to import a command.)

Meanwhile with 6.3.5, the results differ alot: image

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:closed
  • Created a year ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
nikosszzzcommented, Jun 18, 2022

Hmmm, yes. It seems to have improved and is back to normal.

0reactions
AbdelrahmanHafezcommented, Jun 18, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found