logoalt Hacker News

etblgtoday at 12:20 AM5 repliesview on HN

> It's true that Prisma currently doesn't do JOINs for relational queries. Instead, it sends individual queries and joins the data on the application level.

..........I'm sorry, what? That seems........absurd.

edit: Might as well throw in: I can't stand ORMs, I don't get why people use it, please just write the SQL.


Replies

jjicetoday at 12:30 AM

I believe it’s either released now or at least a feature flag (maybe only some systems). It’s absolutely absurd it took so long. I can’t believe it wasn’t the initial implementation.

Funny relevant story: we got an OOM from a query that we used Prisma for. I looked into it - it’s was a simple select distinct. Turns out (I believe it was changed like a year ago, but I’m not positive), event distincts were done in memory! I can’t fathom the decision making there…

show 2 replies
lesuoractoday at 12:59 PM

Can't speak about Prisma (or Postgres much).

But I've found with that you can get better performance in _few_ situations with application level joins than SQL joins when the SQL join is causing a table lock and therefore rather than slower parallel application joins you have sequential MySQL joins. (The lock also prevents other parallel DB queries which is generally the bigger deal than if this endpoint is faster or not).

Although I do reach for the SQL join first but if something is slow then metrics and optimization is necessary.

show 1 reply
pier25today at 12:42 AM

> I can't stand ORMs, I don't get why people use it, please just write the SQL.

I used to agree until I started using a good ORM. Entity Framework on .NET is amazing.

show 2 replies
ketzotoday at 1:30 AM

Not 100% parallel, but I was debugging a slow endpoint earlier today in our app which uses Mongo/mongoose.

I removed a $lookup (the mongodb JOIN equivalent) and replaced it with, as Prisma does, two table lookups and an in-memory join

p90 response times dropped from 35 seconds to 1.2 seconds

show 2 replies
compton93today at 12:23 AM

It is. But wait... it doesn't join the data on the application level of your application. You have to deploy their proxy service which joins the data on the application level.

show 1 reply