Skip to content

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

@ayush-cbh

Description

@ayush-cbh

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"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions