We need to talk about Prisma
We migrated to SQL a month back and our biggest learning was to never use Prisma. Watch the full video to know what happened and how we found a solution.
Read the full blog here: codedamn.com/news/product/don...
Are you confused where to start coding/what to learn/what roadmap to take? Take this free 2 minute quiz: codedamn.com/career-path-quiz
👉 Checkout codedamn on social:
✨ Instagram: cdm.sh/ig
✨ Twitter: cdm.sh/twt
If you found the video valuable, please leave a like and subscribe ❤️ It helps the channel grow and helps us push out more valuable content.
✨ Tags ✨
#coding #sql #migration #prisma #mongodb
✨ Video Tags ✨
Never Use Prisma
We migrated to SQL. Our biggest learning? Don't use Prisma.
Don't Use Prisma.
Пікірлер: 269
But the marketing people say Prisma + Planetscale has "limitless scale". Thanks for the eye opening story.
@milon27
Жыл бұрын
would you please create a benchmark video on prisma and drizzle
@tenthlegionstudios1343
Жыл бұрын
Ya super eye opening. Really appreciate the investigation. Not using SQL features - merging itself. Just Yikes. I mean it does make sense why its easy to use and feels good as an ORM - because it isnt using the underlying SQL features...
@guytonedhai
Жыл бұрын
OMG! Fireship is here!
@dhaw
Жыл бұрын
We need "Prisma for haters" video
@henninghoefer
Жыл бұрын
Have you thought about updating the Prisma-in-100-seconds video?
Thank you so much, starting a project with Prisma right now, will take your findings here seriously to change the stack.
I tried Prisma for a project last year, I was using also PostgreSQL for data, I ended up ditching it as soon as I realised how complex code starts to get with simple SQL joins, and several gotchas like no support for some native data types. I ended out rolling with Postgres.js, a super fun and simple to use lib, actual SQL on string templates, with all the safety and performance Jazz.
This is literally a great video to tell how real engineering should be taken care off, thanks for sharing the learnings with us 🔥
I have found avoiding joins to be a huge plus in terms of performance. In terms of serializing rows it gets exponential if you use a traditional left join.
@kanyevest
Жыл бұрын
interesting. so do you think prismas method could be faster?
@2penry2
Жыл бұрын
@@kanyevest The pure SQL query is probably faster but I've experienced that when fetching many items with deep nested relations Prisma can be faster. (not the SQL execution time. But the JS layer mapping the rows back to an object.
Thanks for sharing the experience with us !
Went through the same thing. Had a large backend entirely written with Prisma. Performance on complex queries was abysmal. Rewrote everything with Kysely (still using Prisma migrate, of course) and things couldn't be better.
@igalklebanov921
Жыл бұрын
❤from Kysely.
This is actually an eye opener, I watched this video till the end!
such a great summary, thank you a lot 🎉🎉
how to use prisma schema for migration and stuff and use kysly or drizzle for run query?
Fantastic video, learned so much.
Would love to see some of your test results between Keysly and Prisma (and maybe a control - just raw queries). I wonder if there’s a place along the curve where it does perform better and where it flips. Data is > anecdote
I watched this to the end. Thanks for sharing
This is common issue in majority of frameworks. Until we run on large datasets there will be some or other issue maybe related to performance or maybe writing complex queies.
"I watched this video till the end!" Thanks for sharing your experience with us Mehul 🙏
I wonder if the size issue is actually the web assembly VM glue that is needed to run the rust binary in a lambda?
I have to say, a lot of points you raised up are because of not digging enough in the documentation or not understanding simple architecture choices. I'll have to say that the most 2 biggest cons of prisma are: 1. The giant rust binaries with the graphql bindings. 2. The connection process on each query. BUT, regarding the point of prisma not doing SQL joins, why is that and why it's actually good. when you use realtionMode prisma, it's stated in the docs(you showed the actual page when it's documented) , that with the foreign key simulation, no joins can happen because it's depended on the foreign key rules. this means if you used prisma, with other SQL providers that support relation foreign keys, prisma would use the SQL joins. but why is that, why use SQL without abusing the power of JOINs. well, it not a decision by prisma, or even PlanetScale, it's a choice by Vitess... you see, we all love joins because of their ease to use and how well they simulate real world scenarios, but JOINs are very low performant on big databases, with huge amounts of rows, so because of that there is no native support for SQL joins in prisma. in the early days of Facebook, once they started to really grow, there was a small "rule" that passed through Facebook, and that's not to use SQL joins anymore because of poor performance.
@TheIpicon
Жыл бұрын
regarding the 2 points I mentions in the cons, prisma are working to fix that and they know about it. there's an experimental feature in prisma, to stop using the graphql bindings and move to json format.
@TheIpicon
Жыл бұрын
I'm not a prisma hype fan, I'm just here to fix false accusations... after FIreship mentioned it in his last video
@jvmachado1204
10 ай бұрын
Excellent observations. Quite clarifying and as free of biases as possible. Thanks for the infos.
Wow, thanks for working through this in public. ❤
Is there any specific reason for choosing query builder and bot orm like sequelize
This is pure gold 💯
I went through exactly the same situation and ended up exactly where you are now except for aws aurora i use neon for now but i plan to switch to aurora when the work load gets more consistent
This was refreshing, i went on a personal research phase last week about orms in js and decided not to touch them unless it is a project am using just to learn something
I'm curious about this. In recent updates they have really been focusing on performance and overall production size (engine size and prisma client size). The transaction thing is still a big worry through. Hopefully they see this video.
I use very simple stack neon database with Hasura and it's working really well.
man, I've been wondering if prisma will be a good option for scaling, nice video man
Can you make a video on the current architecture and tech stack of codedamn?
That was a great video, that brings so many doubts and thinking about the prism. Actually, I started a project a month ago and used the prism in it. with this new information you give, I must think twice about that.
Amazing video. And whilst I share the sentiment I'm still blown away by the level of overengineering some Devs will resort to not write SQL and/or because they're obsessed with types. I feel the lessons here are not just about Prisma or ORMs in general but also how we got here. I see too many devs and projects fail because they don't focus on simplicity and delivering functionality.
I watched this video till the end!
Almost migrated to prisma and planet scale from mongodb. Now reconsidering 😢 Thanks 😊
This video made a great influence on the dev community, many youtube creators are now shifting from prisma to other alternatives! Thanks Mehul
Anyone know the performance comparison between Prima ( Javascript ) and Npgsql ( c# ) connecting to Postgres ? Anyone had the experience ? I used npgsql before, so I think if Prisma can perform better, then I can still use it. Thanks very much.
so i was on the fence of learning database i know mongoDB and how to use it raw so what should i learn next
I watched it till the end ❤
well had to watch many times to understand the whole concept
Spot on, this happened with us as well, we dropped Prisma few days back.
Hey can you please create a video on what tech stack you use for you start up please it would be really helpful
What about the prisma 5 i think most the problems have been addressed according to me can you update this video?
I watched til the end! @codedamn, do you know if Sequelize has the same issues?
Perhaps the most informative vid we've watching in probably 3 or 4 years. You likely saved many some significant hassle, thx for sharing this in such detail.
I migrated from prisma to edgedb and their typescript query builder and never looked back. I don't understand why edgedb ain't having the hype it deserves. The dx is very similar to prisma and the flexibility of having graph-like relationships is like a jailbreak from traditional relational databases. The query builder is very heavy on the typescript lsp, but it is beautifully designed. But I believe this last point is going to be solved once the stc compiler (written in rust) becomes mature enough to be able to replace tsc.
So what would you recomend for high amount of data and high performance needed
Really good video! Thank you, just for curiosity what do you think about supabase?
I also jumped on the hype train of planetscale + prisma. Quickly gave up on prisma. It has that extra complexity and abstraction without making life easier. Now I’m using drizzle. I’m not sure if I like drizzle or knex more but they both get the job done
@electrolyteorb
Жыл бұрын
Learn SQL by heart... and just use a Query Builder... You will be fine for 99.999%(most) part.
@ts8960
Жыл бұрын
it makes life 10 times easier. drizzle is a step back in humanity compared to prisma. for example many to many relations are super easy in prisma. in drizzle or other orms u would have to create a middle man table, prisma takes care of that behind the scenes and provides a much easier way to work and understand ur tables. its just baffling that anyone can say such a thing. I guess developers are addicted to complexity and hard work.
@lian1238
Жыл бұрын
@@ts8960 you do you. I guess
@fatal510
5 ай бұрын
@@ts8960it’s telling that you think that is “hard work” that is easy. You are a trash dev who needs shit like prisma to hold you
10:20 knowing nothing about Prisma but from experience with both SQL and noSQL, shouldn't opration without foreign keys be heavily dependant on table indexes? Did you try any dry-run? I watched this video till the end
I tried building a chat application with prisma and planetscale, but the queries are hella slow. There's no such thing as real time in my application. Don't know if that a mistake on my part or what
Reminds me a lot of Gatsby. They created a system that didn't scale at all and added solutions just to fix the problems they created for questionable reason.
@MrJfergs
Ай бұрын
Hype driven development
Thanks for bringing this up, the schema migration for prisma is also a headache.
You could just replace Prisma with a raw query builder for your purposes. I like the idea of Planetscale. It looks promising.
Such a letting down, was practically picking Prisma and PlanetScale for a project.
The GraqhQL bindings on Prisma I believe have been extracted or eliminated from its application code
@philheathslegalteam
Жыл бұрын
Yea if you enable jsonProtocol feature. This still doesn’t fix the engine itself though, they’re not taking advantage of sql fully.
Django+Postgresql never dissapoints. EC2 never dissapoints.
Every time I leave knex and objection I find myself running right back. A simple query builder goes a long way!
2 questions any reason for Not using Sequelize as the ORM and any reason for not using RDS of AWS?
@milon27
Жыл бұрын
sequalize is very bad in typescript.
@souravdas423
Жыл бұрын
@@milon27 Oh I have never tried that thanks
Query builders win again, ORMs are useful for simple applications but for more complex applications query builders might be a better option. Thanks for sharing
@quocthinhhuynh2134
Жыл бұрын
I am with you, my company project has a few tables with million rows and there are frequently joined. Therefore, being able to write my queries with SQL-like syntax is so crucial, as I can optimize them, if need be and I dont need to learn a new query language
@codedamn
Жыл бұрын
We were using mongoose as an ORM in production so were under the impression that Prisma should work reasonably well for the same work loads. Turns out we were wrong
@MrJellekeulemans
Жыл бұрын
Typeorm includes a query builder, making it a perfect balance
@igalklebanov921
Жыл бұрын
@@MrJellekeulemans A query builder which is not type-safe.
With my experience in web development, I have often seen new tech being hyped but failing with actual production use cases. Most of the time all you need is Postgres/mysql + Redis and thats all, its battle tested and can handle most use cases. If you find your self reaching out for some other nosql DB because of performance or scalability then congratulations your product is super successfull and you can probably afford to hire a big team of engineers and figure it out, but other than that for most use cases I stick to postgres + redis. Use the hype stacks in your personal project. For production usage stick to battle tested og databases. Databases are no joke, I like my data consistent and clean, and RDBMS acid properties ensures that.
@thienhuynh7962
Жыл бұрын
I think you kinda miss the point here cuz prisma is an ORM not a DBMS
@aymanpatel5862
Жыл бұрын
Prisma was also a hyped up ORM. Sacrifices a lot of DX for poor Performance
@nithinbhandari3075
Жыл бұрын
Seniors nahi manenge bhai.
Prisma supports foreign keys. You build it right into the schema. I am not sure on the choice of PlanetScale, when you have cockroachdb instead for a distributed db out of the box. Prisma doesn’t have native support for joins in its query language, however you can perform joins by use of the “include” payload in the prisma transaction. I do this all the time. This video seems to be about folks migrating from nosql to sql and not understanding proper data architecture
I'm using supabase on a new project. I dumped MongoDB completely and the more I get back into SQL I am really wondering why front end developers should ever design the schema for a database. That should be done in the database and functions/stored procedures should define what can be called by the front end developers. In Supabase you can use RPC to call sql functions.. btw Running redis locally is easy with a docker container, but hosting it you should just use a service like upstash
@c0ldfury
Жыл бұрын
Front end devs want the schema so they can have access to their precious types and autocomplete. Personally I just build a rest server from Go to access the db.
Django ORM is great for SQL. It is battle tested and has been here around many years.
I was actually just learning about orms in js... Just curious, did you consider other big names in js orm like sequelize and typeorm. I tried sequelize, and it does create joins. Was just wondering if they are also less performant for complex queries?
@GabrielGasp
Жыл бұрын
Never used TypeORM but Sequelize experience when using typescript is a nightmare, the library has basically 0 support for typescript, relying on third-party "addons" to make it somewhat usable. I used Sequelize a lot in the pre-typescript era but nowadays it’s almost impossible to build production grade nodejs application without typescript. The Sequelize team says that v7 will bring full support for typescript but I’ll believe it when I see it.
I believe that you move away from prisma BEFORE they make an update to their engine, which is said to optimize the cold start up to 9x faster and the query to run faster thanks to the removal of GraphQL roundabout. What is your take on that sir?
@web_dev_cz
Жыл бұрын
My answer as an enterprise worker is: Good for them but I will not be waiting for basic funtionaliity to be pushed. Also I do not think that speed was his (and mine) biggest problem.
@thienhuynh7962
Жыл бұрын
@@web_dev_cz why not though? Since prisma has removed GraphQL and tried to work nicely with the database, its only major concern now is performance, as how every orm should because they're making the performance/productivity tradeoffs.
prisma made an update in version 4.12 to speed up the cold starts
@kengreeff
Жыл бұрын
We are using it, doesn’t make a massive difference though if I’m honest
I enjoy using Prisma, therefore, I was skeptical about its scale. Because anything that is enjoyable or easy to use, just cannot scale 😂
I just migrated from Prisma to Drizzle in a self managed database. You'll work closer to bare metal sql but they just released Relational queries yesterday with very easy to follow syntax! I recommend you check it out.
@ikeako
Жыл бұрын
Started migrating to drizzle on a project yesterday before they dropped relational queries. That library was a lifesaver 🙏
I had a similar experience with prisma, in the process of the new back end 😂
I WATCH THIS VIDEO TILL THE END!
loved it
Please review the Drizzle Orm. People are saying it Will change.
Very good video. Thank you. I may switch from prisma runtime in the future. Luckily I wrote all my db interactions using a service oriented architecture, so this change will (hopefully) be trivial.
Everything in the programming world became strange and non-reasonable. If you write an app in NextJS by using Prisma, some UI like Radix, and so on, and everything is based on JS, there is nothing from JS plain code but the weird syntax of the libraries or frameworks. Every new package, libraries or frameworks tries to bring something new, something like BIG BOOM, but everything ends with confused developers that have to investigate the benefit of new technologies and if they bring something good or bad. And it makes a chaos in my head.
PlanetScale has a JS serverless driver based on fetch API. It's a good lightweight alternative to Prisma
@codedamn
Жыл бұрын
We considered it but it wasn’t type safe so was a deal breaker
All I can say is that Rust is bloated af, and I won't use any Rust in production until it's able to produce sane size binaries. In one of my projects, I tried to compare the binary sizes, and it was a "wow": Rust produces a 70mb binary, where the same program in C was like 350kb
But is it same with the new JSONSchema engine in Prisma?
@milon27
Жыл бұрын
i want to know it also?
@kengreeff
Жыл бұрын
It still isn’t the fastest after the update. Hopefully more improvements soon!
this expalins alot There should be a bench market test on all typescript ORM I was a typescript ORM called Deepkit is one that I am interested in there benchmark is to good to be true. They claim to be 4 times faster than prisma and TypeORM
Prisma bringing everything to memory to perform a simple join sounds a lot like a fancy PrestoDB/TrinoDB. And, btw, this is a great example on why to never make a decision based on the product's landing page and the big words used in it.
greatvideo
So you first choose this solution and then after things became bad, you choose to read documentation. And nobody in the team knew this. Great engineering.
@rajusharma823
Жыл бұрын
prisma is only better for simple sites with nothing much happening
@heyjitendra
Жыл бұрын
@@rajusharma823 I am curios if DrizzleORM fixes these issues
@arogueotaku
Жыл бұрын
I guess they were aware of the points but unaware of the performance issues it might cause in Serverless Apps. I don't think the documentation mentions anything about the dealbreaker points he brought up. It's not about great engineering. It's about, trusting a widely praised and accepted tool and diving in blind without previous experience with the same tool. Lesson learnt I guess.
@aryankumar87771
Жыл бұрын
@@arogueotaku It's mentioned in the docs, for serverless framework
I have sveltekit with prisma all code under 200k after build
where is your discord channel link ?
We started with Postgres but end up with Planetscale 😒
data proxy is to bypass direct db connection limits, i don’t think its a problem they introduced
@codedamn
Жыл бұрын
If Prisma opens a transaction on every small insert then you’ll exhaust the connection limits pretty easily for your native database (since a transaction blocks the full tcp connection)
@shafu_xyz
Жыл бұрын
@@codedamn yeah that’s why they introduced proxy service, this issue between serverless and native db connection is not prisma thing, as far i understand
We have a LOT of DB relations in the project so Prisma is the best option for us
what about drizzle?
the main reason i use prisma is type safety, but the user experience is not that great, one of the reason is code generation and schema language. Now I use kysely, pure typescript
@igalklebanov921
Жыл бұрын
♥from Kysely.
what about Sequelize?
make a video on postgres and drizzle orm please
I did not know Prisma did not have SQL-level joins. Isn't Planetsclale pricing based on number of ROWS read and written? Sounds like they work horribly together.
you should have import prisma from "prisma/edge"
I watched this video till the end
Drizzle is promising, and Prisma is getting better lately
I keep seeing prisma everywhere as a developer even thought I haven't use sql for months.... Almost got tempted to give it a try due to its huge popularity, but sometimes the simple way is the best way to do things without any "magical" layer in between your lovely queries and a beast database like postgres. Thank for this video, Im gonna stay away from prisma after knowing your experience.
@milon27
Жыл бұрын
try it yourself then go away.
@philheathslegalteam
Жыл бұрын
Not everyone has a fundamental understanding of how this system works. Prisma can be used in various ways. It’s perfectly fine to use now that they’ve removed the DMFF layer causing extreme performance problems, however, I still prefer a different way: 1. Use Prisma as the schema and migrator tool (this is imo the best toolset available for RDBMs). 2. Use their AST mode to generate a custom client (we use kysely-prisma) 3. Now you have a Typesafe query client writing extremely performant queries. 4. Since we use kysely-prisma, we can use our client at the edge using planetscale or neon drivers.
@milon27
Жыл бұрын
@@philheathslegalteam would you share code sample with kyles with prisma schema?
@codedamn
Жыл бұрын
Phil is right. Prisma’s tooling is amazing for migration and schema. We don’t use it on runtime though
Drizzle is awesome, has integration for planetscale also
I watched this video till end
So you guys wanna try out drizzle now?
🎉
luckily EdgeDB exists, I no longer have the need to think about ORMs :)
What was one of the reasons that made the team think about moving out of mongoDB?
@YOUdudex
Жыл бұрын
He did tell in the video already, relational database give you consistent data and not cause dumb bugs
@gatodetaco
Жыл бұрын
@@YOUdudex thanks
So all this time @t3dotgg was only building toy apps that uses the t3 stack with planetscale, prisma etc.
@macctosh
Жыл бұрын
no he had a similar issue a while ago but he claims that Prisma fixed the problem and it's now 1000x faster. Nevertheless, he's of the mindset of move fast and break things and fix them later when you have amassed a big enough market share to get funding which will allow you to hire specialist and move things in-house in short he accepts technical debt in exchange for faster continuous delivery. I personally don't subscribe to that way of thinking, However he is succeeding as his startup PING.gg is getting funding but it only has six employees. I am really curious what the codebase will look like when he reaches 30 employees?
@thienhuynh7962
Жыл бұрын
@@milon27 Can you elaborate more on the benchmark. Curious to know
@milon27
Жыл бұрын
@@thienhuynh7962 sorry i was wrong prisma is slower than drizzle but i am still not sure about should we stop using prisma or not.
Can you make one video where you will say why are you moving from noSql to Sql database and what are pros/cons from each other ? p.s. great deep research job through experience.
I would love to know why you migrated from MongoDB