Easiest way to investigate a slow Prisma D1 query?

I have an instance of Prisma that I'm using to run a query. The code consistently takes 200 - 250ms to run. On the D1 dashboard the query time is 0.4ms. I would like to understand where that extra time is coming from (serializing the result, waiting on the d1 api, etc) What's the easiest way to do that with this one query?
const now = new Date();
const memberOrgs = await context.locals.prisma.user.findFirst({
where: {
email: context.locals.user?.email,
},
include: {
members: {
include: {
organization: true,
},
},
},
});
console.log("org query", new Date().getTime() - now.getTime());
const now = new Date();
const memberOrgs = await context.locals.prisma.user.findFirst({
where: {
email: context.locals.user?.email,
},
include: {
members: {
include: {
organization: true,
},
},
},
});
console.log("org query", new Date().getTime() - now.getTime());
Solution:
ah, I found the issue. Each query is taking 70ms and prisma is generating 3 queries and sending them in series! https://github.com/prisma/prisma/issues/23348...
GitHub
Support new relation load strategy for SQLite (relationJoins prev...
In versions 5.7.0 and 5.10.0 we released support for a new relation load strategy for PostgreSQL and MySQL as part of the relationJoins preview feature: Documentation: https://www.prisma.io/docs/or...
Jump to solution
3 Replies
Prisma AI Help
You selected the carefully hand-crafted route. A dev artisan will respond soon. Meanwhile, the #ask-ai channel awaits if you're curious!
Solution
dan—1106
dan—11067d ago
ah, I found the issue. Each query is taking 70ms and prisma is generating 3 queries and sending them in series! https://github.com/prisma/prisma/issues/23348
GitHub
Support new relation load strategy for SQLite (relationJoins prev...
In versions 5.7.0 and 5.10.0 we released support for a new relation load strategy for PostgreSQL and MySQL as part of the relationJoins preview feature: Documentation: https://www.prisma.io/docs/or...
Nurul
Nurul7d ago
Glad to hear that this is resolved. Thanks for marking the solution 🙏

Did you find this page helpful?