Performance problem

Hi all! We have a problem with performance. We use prisma 5.21 and I measure time for a call where we get a batch of 50 objects and the response is about 800kb. Currently it takes about 1.9s to get the response from prisma. Does that sound reasonable? Any ideas on where I should start troubleshooting? My code below: const recruitments = await prisma.recruitment.findMany({ where, take, // 50 skip, orderBy, include: { company: { include: { contacts: true }, }, recruiter: true, recruiterGuests: true, recruiterExternals: true, jobAd: true, process: { orderBy: { order: "asc", }, }, regions: true, occupationalAreas: true, occupationalGroups: true, applications: true, profileFile: true, recruitmentSelectedPublishChannels: { include: { publishChannel: { include: { selected: true, }, }, }, }, addons: true, selection: { include: { recruitments: true, answers: true, }, }, symbols: true, }, })
4 Replies
Josef Henryson
Josef HenrysonOP•5d ago
I tried to remove part of the select and then I got response time 500-700ms instead which is better, but I need that info, can I optimize that in some way? Removed this: recruitmentSelectedPublishChannels: { include: { publishChannel: { include: { selected: true, }, }, }, },
Nurul
Nurul•5d ago
Hello @Josef Henryson 👋 Did you try using Prisma Optimize? It is built for the exact use case you are looking for. We would appreciate any feedback you can provide while trying out Prisma Optimize 🙂 https://www.prisma.io/optimize
Prisma
Prisma Optimize: AI-driven query analysis
Gain deep insights and get actionable recommendations to improve your database queries, making your app run faster.
Josef Henryson
Josef HenrysonOP•2d ago
Hi, thanks for your reply. I have not tried that. I will check it out 🙂 Do you think it may be wotrth trying out dataloader first? Side question: I have tried to log response times. My Prisma query seems to take about 640.426ms, the same response in the browser is about 2.26 s. I use an express nodejs server with Apollo client & server. This is done on localhost. Isn't it a lot of time overhead between the prisma response and arrival on client? Of course, my last comment is not prisma dependent, but I guess many of you also use Apollo server and might have some experience on this?
Nurul
Nurul•17h ago
I would recommend using tracing to see where exactly is the time spent. This would allow troubleshooting the overhead:https://www.prisma.io/docs/orm/prisma-client/observability-and-logging/opentelemetry-tracing
OpenTelemetry tracing (Preview) | Prisma Documentation
Diagnose application performance with detailed traces of each query.
Want results from more Discord servers?
Add your server