Skip to content
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

[MongoDB] Performance issue in findMany() query execution with in #15983

Closed
ayush-cbh opened this issue Oct 25, 2022 · 5 comments
Closed

[MongoDB] Performance issue in findMany() query execution with in #15983

ayush-cbh opened this issue Oct 25, 2022 · 5 comments
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: findMany() topic: in topic: mongodb topic: performance/queries topic: performance
Milestone

Comments

@ayush-cbh
Copy link

Bug description

I have a nextJS project and I am using Prisma as an ORM for mongoDB.
I need to execute findMany for a collection having 1 million documents.

Performance change:
When I try to execute the same aggregation in mongoDB compass it takes less than 0.5 sec
while with prisma it takes around 20 sec to get the result.

How to reproduce

Create a collection with 1 million documents.
Search 5 document through id with the help of findMany()
It will take around 20 sec to execute the aggregation.

Expected behavior

It should return asked documents in (0.5 - 1 ) sec.

Prisma information

model collection_name {
   id                       String                  @id @default(auto()) @map("_id") @db.ObjectId
  name                  String?
  age                     Float?
  url                       String?
}
this.prismaClient.collection_name.findMany({
      where: { id: { in: [id1, id2, id3] } }
    })

Environment & setup

  • OS: macOS
  • Database: MongoDB
  • Node.js version: v16.17.1

Prisma Version

"prisma": "^3.12.0"
@Jolg42
Copy link
Member

Jolg42 commented Oct 26, 2022

@ayush-cbh Do you see the same problem with a more recent version of Prisma? If you could try >4 that would be interesting, the latest is 4.5.0.

@Jolg42 Jolg42 added the bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. label Oct 26, 2022
@paulrostorp
Copy link

this is a duplicate of #14871 and #12793

@paulrostorp
Copy link

@ayush-cbh see #15156 (comment)

@Weakky Weakky changed the title Performance issue in findMany Query execution. [MongoDB] Performance issue in findMany Query execution. Jul 7, 2023
@janpio janpio changed the title [MongoDB] Performance issue in findMany Query execution. [MongoDB] Performance issue in findMany() query execution Apr 24, 2024
@janpio
Copy link
Member

janpio commented Apr 24, 2024

@ayush-cbh It's been a while, but can you maybe provide both the aggregation you run manually in MongoDB compass and the command that Prisma generates? If those are identical, then this would mean this is not a case of the same issues that Paul linked to above and mean that we have to treat this problem separately. Thanks.

@janpio janpio changed the title [MongoDB] Performance issue in findMany() query execution [MongoDB] Performance issue in findMany() query execution with in Apr 24, 2024
@laplab
Copy link
Contributor

laplab commented May 13, 2024

This performance problem is fixed in Prisma 5.14.0

@laplab laplab closed this as completed May 13, 2024
@laplab laplab added this to the 5.14.0 milestone May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: findMany() topic: in topic: mongodb topic: performance/queries topic: performance
Projects
None yet
Development

No branches or pull requests

5 participants