Drizzle vs. Prisma: why does Drizzle need less row reads?

I deployed a project to PlanetScale and noticed a high number of row reads for searching a table of 500 rows. I didn't think anything of it. I've been wanting to switch to Drizzle ORM anyway after I saw the TypeScript schema definition. I made the switch with everything the same (except I'm not sorting by id) and noticed a HUGE rise in read/return efficiency with Drizzle. The SQL query is the same. The indices are the same. I did notice Prisma prepends the db name and table everywhere, like db.Table.column wherever it can. Drizzle doesn't. I'm impressed. Is there anything I'm missing? PlanetScale's row reads is generous, but there's a lot of savings here.
Solution:
Yeah, prisma doest use joins, it makes individual calls and combines the data.
Jump to solution
15 Replies
Neto
Neto•17mo ago
drizzle makes a single query to the database prisma does multiple db calls and stitch the responses
Solution
Kasper
Kasper•17mo ago
Yeah, prisma doest use joins, it makes individual calls and combines the data.
Neto
Neto•17mo ago
also isnt a planetscale related thing if you execute on local sqlite, prisma also does multiple queries
Kasper
Kasper•17mo ago
You can learn more about it here: https://www.youtube.com/watch?v=jqhHXe746Ns
ThePrimeTime
YouTube
Migration Lesson: Don't Use Prisma | Prime Reacts
Recorded live on twitch, GET IN https://twitch.tv/ThePrimeagen Article: https://codedamn.com/news/product/dont-use-prisma Mel, "The Milk", key: https://twitter.com/MelkeyDev MY MAIN YT CHANNEL: Has well edited engineering videos https://youtube.com/ThePrimeagen Discord https://discord.gg/ThePrimeagen Have something for me to read or reac...
Neto
Neto•17mo ago
the article that is the source of the video is quite bad but prisma is also at fault here
Kasper
Kasper•17mo ago
Yeah I read the article myself, seemd like they did not know how to use prisma or an orm in general. They also made a lot of wierd assumptions. But that also where I first learned about not using joins
Neto
Neto•17mo ago
using mongodb as a relational db is enough for me to ignore the whole article
Kasper
Kasper•17mo ago
Hahahaha yeah
Quentin
QuentinOP•17mo ago
I'm having a hard time understanding the value of Prisma then and why it seems to show a single query in the PlanetScale insights 🤔 Anyway, I'll take the W with Drizzle. Thank you!!
Neto
Neto•17mo ago
From a historical background, before prisma there wasn't good options for a typescript orm The whole dsl file, plus "easy sql" with "includes" and such You can do a lot more without knowing sql
Kasper
Kasper•17mo ago
I switched to drizzle when Theo made that first video, I have no regrets
Neto
Neto•17mo ago
From a technical pov, most applications won't reach the scale of having issues with sql performance If you need enough of perf that Prisma isn't capable, you never had to use Prisma from the t3ggSip
Quentin
QuentinOP•17mo ago
Actually good point, the DX beats writing SQL queries 😅
Kasper
Kasper•17mo ago
They do have something similar to prisma now
Want results from more Discord servers?
Add your server