Performance: Relations in Prisma
MEDIUM IMPACT
This affects database query speed and server response time when fetching related data.
const users = await prisma.user.findMany({ include: { posts: true } });const users = await prisma.user.findMany(); for (const user of users) { user.posts = await prisma.post.findMany({ where: { authorId: user.id } }); }
| Pattern | Database Queries | Server Response Time | Client Impact | Verdict |
|---|---|---|---|---|
| N+1 Query Pattern | N+1 queries | High latency | Slow interaction response | [X] Bad |
| Single Query with include | 1 query | Low latency | Fast interaction response | [OK] Good |