Skip to content

Performance degradation when upgrading from Mongoose v4 to v8 (findOne slower than find) #14906

Open

Description

Prerequisites

  • I have written a descriptive issue title

Mongoose version

8.6.3

Node.js version

v18.20.4

MongoDB version

4.4.25

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

No response

Issue

Description:

I am currently in the process of upgrading Mongoose from version 4 to version 8 in our project, and I've encountered a significant performance issue.

Summary:

  • v4 performance: Acceptable speeds.
  • v8 performance: Approximately 40% slower for findOne queries, despite find queries operating as expected (and even faster than before).

Details:

  • Indexes and schema remain identical between v4 and v8.
  • No special configurations or optimizations were applied during the upgrade.
  • find queries exhibit improved performance under v8, but findOne queries are noticeably slower.
  • same setting & same environment & same index

Steps to Reproduce:

  • Run the same query using findOne on both Mongoose v4 and v8.
  • Compare the query performance between the two versions.

Expected Behavior:

  • Performance should be on par or improved in v8, compared to v4.

Actual Behavior:

  • findOne queries are approximately 30% slower in v8 than in v4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions