-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 with nested take
on many-to-one relationship
#13865
Labels
bug/2-confirmed
Bug has been reproduced and confirmed.
kind/bug
A reported bug.
team/client
Issue for team Client.
topic: include
topic: mongodb
topic: performance/queries
topic: take
Milestone
Comments
This might be related to #10949 with SQL databases. |
matthewmueller
added
team/client
Issue for team Client.
topic: mongodb
topic: performance/queries
bug/0-unknown
Bug is new, does not have information for reproduction or reproduction could not be confirmed.
labels
Jun 21, 2022
matthewmueller
added
topic: core query optimization
and removed
topic: core query optimization
labels
Jul 13, 2022
Jolg42
added
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
and removed
bug/0-unknown
Bug is new, does not have information for reproduction or reproduction could not be confirmed.
labels
Sep 7, 2022
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
janpio
changed the title
performance issue with nested
MongoDB: Performance issue with nested Nov 4, 2022
take
on many-to-one relationshiptake
on many-to-one relationship
janpio
added
bug/2-confirmed
Bug has been reproduced and confirmed.
and removed
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
priority/high
labels
Nov 4, 2022
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This performance problem is fixed in Prisma 5.14.0 |
This was referenced Jun 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug/2-confirmed
Bug has been reproduced and confirmed.
kind/bug
A reported bug.
team/client
Issue for team Client.
topic: include
topic: mongodb
topic: performance/queries
topic: take
Bug description
It seems like a nested
take
(inside ainclude
) query doesn't actually include a$limit
operator on the mongodb aggregation pipeline which i believe causes mongodb to return all document from a collection, this results in a really slow query time when the collection has lots of documents. So this is how it goes from my understanding:this means a large chunk of data has to be downloaded only to return 3 documents...
for example, the query included in the prisma information section takes around 1:33 minutes on my internet (db on mongodb atlas)
whereas an equivalent query using findUnique and aggregateRaw took around 700ms:
How to reproduce
git clone https://github.com/itsarnob/prisma-nested-take-repro
yarn seed
to seed the database with a chat and 100k messagesyarn start
to see the time differences between nested take and the equivalent query using findUnique & aggregateRawExpected behavior
$limit
operator in the aggregation pipeline so mongodb returns n documents instead of all documents in the collection.Prisma information
Schema
Query
aggregation query logs
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: