-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 nested/include
query slow
#17142
Comments
Thanks for the nice investigation @foghina 👍 |
Happening to us as well, it wouldn't be usable at scale. |
My issue is related, but isn't for includes. When trying to do a query with Prisma using Slow solution:
In order to use the index for each id I did:
|
select has the same problem. i think this is a very serious issue and should be tackled with high priority. |
Yep, it's because of the export function getCreationsFromShareTokens(shareTokens: string[]) {
return prisma.creation.findMany({
where: {
shareToken: { in: shareTokens },
},
})
} |
Any news on this specific problem? I feel like mongodb isn't really being taken care of on prisma anymore |
include
query slow
This performance problem is fixed in Prisma 5.14.0 |
Bug description
It seems that, when using
include
with MongoDB, the generated query uses "in" instead of "eq", resulting in significantly slower queries.How to reproduce
Relevant schema bits:
Now, say I have the
imdbId
for a series, and I want to fetch it + all the episodes. The following takes under 130ms to run on my dev machine:However, the following takes over 2.5s:
Now, I've enabled query logging and saw the following:
I think the key here is that the slow query uses operator
$in
, whereas the fast query uses$eq
.Expected behavior
The query using
include
should not take 20x longer.Prisma information
included in repro
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: