-
Notifications
You must be signed in to change notification settings - Fork 55
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
Question: N + 1 Query issues #1
Comments
The main thing we create this package is facing N + 1 query issue in my private project Example query query {
findOneUser(where: { id: 1 }) {
id
email
name
posts(
where: { title: { contains: "a" } }
orderBy: { createdAt: asc }
first: 10
skip: 5
) {
id
title
comments(where: { contain: { contains: "a" } }) {
id
contain
}
}
}
} convert to {
select: {
id: true,
email: true,
name: true,
posts: {
select: {
id: true,
title: true,
comments: {
select: { id: true, contain: true },
where: { contain: { contains: 'a' } }
}
},
where: { title: { contains: 'a' } },
orderBy: { createdAt: 'asc' },
first: 10,
skip: 5
}
} with this way you just query what the frontend ask and save your performance old wayIn this query example if we have result with 10 users so i was doing 10 queries my wayconvert info to be available prisma select object you will do one query to get all what you need the query was take 40 second before now take less than 100ms I hope i made it clear |
Hello, Very interesting! Thanks a lot for clearing that up. Is it possible to give an example for converting info to be available prisma select object (your suggested way)? Thanks a lot in advance! |
It's already in my tools https://github.com/AhmedElywa/prisma-tools/tree/master/packages/select |
This is great! Thanks a lot for all your amazing work! |
I just wanted to say thank you for creating the |
@nghiepit Thank you for your positive feedback |
I have trouble with @@id. its giving me error. |
Hello,
This is a great package and thanks for creating this awesome package, now my question is that, does this package handle N + 1 Query issues?
Thanks a lot in advance.
Ali
The text was updated successfully, but these errors were encountered: