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:Jump to solution
Yeah, prisma doest use joins, it makes individual calls and combines the data.
15 Replies
drizzle makes a single query to the database
prisma does multiple db calls and stitch the responses
Solution
Yeah, prisma doest use joins, it makes individual calls and combines the data.
also isnt a planetscale related thing
if you execute on local sqlite, prisma also does multiple queries
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...
the article that is the source of the video is quite bad
but prisma is also at fault here
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
using mongodb as a relational db
is enough for me to ignore the whole article
Hahahaha yeah
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!!
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
I switched to drizzle when Theo made that first video, I have no regrets
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
Actually good point, the DX beats writing SQL queries 😅
They do have something similar to prisma now