Prisma 5: Faster By Default | Prime Reacts

Поделиться
HTML-код
  • Опубликовано: 14 июл 2023
  • Recorded live on twitch, GET IN
    / theprimeagen
    Article: www.prisma.io/blog/prisma-5-f....
    Author: Alex Ruheni | Twitter: @ / ruheni_alex
    MY MAIN YT CHANNEL: Has well edited engineering videos
    / theprimeagen
    Discord
    / discord
    Have something for me to read or react to?: / theprimeagenreact
  • НаукаНаука

Комментарии • 93

  • @beni69
    @beni69 10 месяцев назад +145

    pris'MA NUTS

  • @Cyber_Lanka
    @Cyber_Lanka 10 месяцев назад +40

    Clarification about that previous article. That relationship issue only happens when you specify relationMode = "prisma" in the schema file. This tells Prisma to emulate foreign keys because the underlying DBMS doesn't support that. In other cases, Prisma works the same way. It will do all the joins using the DBMS/SQL, not using their Rust engine thing.

    • @darshandev1754
      @darshandev1754 8 месяцев назад +2

      thats great to hear

    • @user-mm6op9sz7t
      @user-mm6op9sz7t 5 месяцев назад +1

      This doesn't seem to be true in my case. I have no relationMode setting in my schema file and I see individual select statements on all tables when fetching with joins. In other words of you want to join table a and b prisma will do two individual select statements on each table.
      I am using postgres so it is not because prisma is defaulting to its 'prisma' relationMode

  • @alsjourney
    @alsjourney 10 месяцев назад +13

    Love these videos. Even though you just react but the input you provide is so valuable

  • @blenderpanzi
    @blenderpanzi 10 месяцев назад +10

    The whole separate process and IPC thing is a big WTF to me. For an ORM? There is a library option where a native library is loaded and no separate process is started. That option was broken for a while because of wrong flags for dlopen() that caused a segmentation fault because Prisma links a different OpenSSL version than NodeJS does.

  • @IzioRomain
    @IzioRomain 10 месяцев назад +1

    Really great to have commentary after the reading with the community 👍
    Was adding more context

  • @mathijsfrank9268
    @mathijsfrank9268 10 месяцев назад +24

    "Most of what youll be doing is basic sql." Tell that to my work where we write almost all business logic in stored procedures that are hundreds of lines long and have existed for over 20 years....

    • @SergiobgEngineer
      @SergiobgEngineer 10 месяцев назад +4

      holy fuck, do we work n the same company? I don't get why my company uses a fucking repository pattern if the chances of us moving to another database are 0% since half of the company's business logic is written in PL SQL right now. Might as well just start calling the database procedures from the Core layer.
      😅

    • @dacam29
      @dacam29 10 месяцев назад +3

      You work for the government or in a big insurance/bank cie!? 😂

    • @Adelphos0653
      @Adelphos0653 10 месяцев назад

      Lol, we use prisma, but we refuse to use stored procedures. We want business logic in our primary code

    • @travishatch6246
      @travishatch6246 10 месяцев назад +3

      Lol just had to troubleshoot a 2000+ line stored procedure that generates its own dynamic SQL statements and inserts them into a temp table from a cursor nested in a cursor
      Then it begins a transaction and opens a cursor to execute the previous generated SQL statements💀

    • @travishatch6246
      @travishatch6246 10 месяцев назад +1

      ​@@Adelphos0653we use an database schema from pre Y2K and up until a year ago all logic was done in the database. Mainly table triggers, dynamic SQL compiling and executing during runtime (to allow for the installed app to be independent of form field additions) and stored procedures.

  • @frosty2912
    @frosty2912 10 месяцев назад +17

    The GraphQL like way transmitted the entire schema to the DB each time, the new way just transmits the bits you need.

  • @oscarmugambi
    @oscarmugambi 10 месяцев назад

    Is there an archive for full length streams? Can't seem to find any on twitch

  • @wchorski
    @wchorski 10 месяцев назад +1

    wondering about anyone's experience with KeystoneJS. Ive started using it for a year, I think it has a great DX but have a feeling it might turn into a big foot gun

  • @guidobit
    @guidobit 10 месяцев назад +15

    I have a feeling Prisma is the Mongo for ORMs: traction trough marketing budget.

    • @night23412
      @night23412 10 месяцев назад +3

      yeah..

    • @zzzyyyxxx
      @zzzyyyxxx 10 месяцев назад +2

      Unlike Mongo, Prisma is actually good.

    • @Alex-kb2ws
      @Alex-kb2ws 10 месяцев назад +1

      ​@@zzzyyyxxxif it's so good, write a computed field query in prisma

    • @HalfMonty11
      @HalfMonty11 10 месяцев назад +12

      Have you used it? It's not trying to be the fastest ORM in the world. If you want absolute max performance all the time, you don't want an ORM. Hand rolled optimized SQL queries is going to win every time. However, what Prisma is amazing at is great support of the most common relational db types and great tooling that allows you to either work with code first or db first approach, generating your models and client and types for you, reducing how much code you have to write and speeding up your code delivery. 3 cli commands and it'll set up your project for you, and you can just start using the client. It gets you off the ground so easy and the docs are great, usage is intuitive. Stop trying to fit it into what it's not trying to be and you might then appreciate it for what it is. If you are going to take the time to include a dependency, it should bring something to the table and what prisma brings is a massive elimination of code and effort on the developers part. That's worth something.

    • @zzzyyyxxx
      @zzzyyyxxx 10 месяцев назад +1

      @@Alex-kb2ws I've literally never had to do that in either Prisma or SQL. If your argument is just, why can't it do something I need in 0.1% of scenarios, then, that's the exception that proves the rule.

  • @Xe054
    @Xe054 10 месяцев назад +1

    What does Prime mean when he says he prefers query builders? What are some good examples of them? Does Drizzle fall into that category?

    • @dima1478
      @dima1478 10 месяцев назад +1

      Drizzle is still ORM. ORM interface with the database so that you can OOP instead of writing SQL. Query builders just make writing SQL easier, but there is no abstraction between.

  • @lilililliilil
    @lilililliilil 10 месяцев назад +1

    still it takes about 3~5 seconds at start. so annoying. thinking to move to Drizzle

  • @spamviking8591
    @spamviking8591 10 месяцев назад +1

    Is this considered good performance? I was working with a bunch of scrubs on a project written in PHP back in 2017. Since none of them could be trusted to do things properly, I wrote an entire query string based query builder that interpreted db relationships based off of foreign keys that could build a complex query with multi layer joins and apply the permissions before executing the query and still managed to return almost every response in less than 150ms on a MariaDB database.

    • @nikhiljugdan724
      @nikhiljugdan724 10 месяцев назад +1

      And how much time did you spend developing it ?

    • @spamviking8591
      @spamviking8591 10 месяцев назад

      @@nikhiljugdan724 a weekend.

  • @SuperDevastetor
    @SuperDevastetor 10 месяцев назад

    Where's the "yesterday's seething article" at?

  • @jdal21
    @jdal21 10 месяцев назад +2

    Sticking with Drizzle though

  • @renatocron
    @renatocron 10 месяцев назад +1

    so, i'm here, 15:05, din't watch no further (and i didn't had a chance to watch the previous episode you talked about), and I'm also interested in how prisma will deal with join and/or competition (hi drizzle). I like the ideia that some queries can be optimized with joins (most of then can, indeed), the real issue is, how to break down the queries into smaller queries without the database feedback, because, if you follow perl/DBIC way to remap/change the query order by to met the query spec, then you potentially get back many many rows, wasting CPU (and in the AWS, bad yet, bandwidth!). So, over simple queries this is already solved by current prisma engine (eg: load all posts with created by (author name+date), updated by(author name+date), if the author repeat in many, the author only get retured once). Exploring more into the more specialized queries, trying new solutions, that depends heavily in the use case, you can change joins by JSON queires or functions that return stable objects (so can be cache inside one transaction in read committed, assuming that this is the most used tx mode) also can lead to moving the load from the process (nodejs:rust-prisma-bind/distributed) to the (most of the time much more expensive aurora/rds) database. So. it's not simple. Prisma can be better, but's not an easy or clear solution to go towards

  • @blenderpanzi
    @blenderpanzi 10 месяцев назад +2

    I don't know what other article this video refers to about the joins (don't see a video from yesterday about the topic) and I don't actually know how Prisma is actually doing it. But if it happens to refer to the include mechanism, of course these are two queries? Like if you query all users born after a certain date and all their files:
    prisma.user.findMany({ where: { birthdate: { ge: date } }, include: { files: true } })
    I assume it will do these SQL queries (like many other ORMs do too):
    SELECT * FROM user WHERE birthdate >= ?;
    SELECT * FROM file WHERE user_id IN (?);
    Where the ? in the second query is the list of user IDs returned in the first query.
    If it would do this instead:
    SELECT * FROM user LEFT JOIN file ON user.id = file.user_id WHERE birthdate >= ?;
    Yes, it would be one query, but it would duplicate all fields of user for each file. That might explode the size of the returned result. If you then have even more includes it would explode the result size exponentially. Don't think that would be good. Don't think that would be what you would write by hand (except when you know the involved joins still keep the result set small, like there are one 3 columns in user and you only have one join). I guess one could have an optimization for when there are only very few columns of user selected and not too many includes, than it could use joins.
    Again, I haven't checked how Prisma actually does this, but I would assume it happens that way for these reasons. Would you use join in any case?

  • @MegaMech
    @MegaMech 10 месяцев назад +2

    I had this on 1.75 speed by default when the video started. Would have been funny if the editor had edited like that as a joke.

  • @jaymartinez311
    @jaymartinez311 10 месяцев назад

    Can somebody tell me how i can just use postgres. No orm’s no abstraction just postgres. Then maybe a package to handle migrations. I know rds for aws maybe with postgres but nothing else?

  • @zaneearldufour
    @zaneearldufour 10 месяцев назад +2

    There's a third party python client for Prisma that is awesome. That's all I know

  • @CamembertDave
    @CamembertDave 10 месяцев назад

    Graph Queel, omg I'm dying

  • @TurtleKwitty
    @TurtleKwitty 10 месяцев назад +6

    Prisma half works with postgres, if they did properly there would be 0 reasons to use mongo, post handles json internally and a TON of features on top of everything mongo has but prisma hides it. The number of fucking times ive had my backend/DB engineer say postgres sucks cause it doesnt handle XYZ but its just prisma hiding that it does is wild

    • @huge_letters
      @huge_letters 10 месяцев назад

      is it prisma's fault a lotta people jump to MongoDB as their first option when they need a db instead of postres or mysql?

    • @TurtleKwitty
      @TurtleKwitty 10 месяцев назад +1

      ​@@huge_letters Prismas fault people go to mongo first? no. Prismas fualt that people don't see there is so much strong tooling in other DBs because prisma is pushed so hard as /the/ single way to access a DB? yes.

    • @huge_letters
      @huge_letters 10 месяцев назад

      @@TurtleKwitty I guess but isn't orm supposed to be for dummies? I'm a dummy and use an orm cause it's easy for me - if you're a db engineer you should know SQL and it's tooling. At least that's the way I see it

    • @TurtleKwitty
      @TurtleKwitty 10 месяцев назад +1

      @@huge_letters you'd think so but so often people just get comfortable in a specific tool/library and don't want to branch out.
      Orm in and of itself isn't for dummies just better DX, some are more simple some are more complex, some have a simple initial interface but still give access to the full complexity when you need it; that last point (that Prisma doesn't do) is exactly the problem I have with Prisma, they went with simple then became the defacto tool so now people are kinda stuck with surface level tooling. It would be a fairly easy solve, just learn to use the db directly but (personal theory) react is pushed so hard as the defacto webdev framework and is unusable without a ton of wrappers and libraries that webdevs engrained in react especially are hard stuck thinking that is there isn't a wrapper to make things usable you just can't use it at all.

    • @yojou3695
      @yojou3695 10 месяцев назад +3

      it's amazing how people in javascript world STILL havent figured out a half decent orm

  • @johnychinese
    @johnychinese 10 месяцев назад +1

    What a name
    Got me there😂

  • @kubre
    @kubre 10 месяцев назад +2

    I don't know I hate kinda bcz it keeps me making restart typescript lsp

    • @FunctionGermany
      @FunctionGermany 10 месяцев назад +3

      pin the generated client file in your IDE. it's annoying and a workaround, but it helps.

  • @devmesh5340
    @devmesh5340 10 месяцев назад +1

    Dungeon what?😂😂

  • @unersame8253
    @unersame8253 10 месяцев назад

    I've been using Prisma since about 2 years ago. I hate it.
    I'll keep on using it since I hate all ORMs, and it's mainly a skill issue.

  • @andresgutgon
    @andresgutgon 10 месяцев назад +2

    The thing with not doing joins is a good reason to try Drizzel

    • @ChillAutos
      @ChillAutos 10 месяцев назад +4

      Try drizzle with more than 10 tables lol. Shit is painfully slow right now, ts lang server 5-10s to catch up and even crashes.

    • @Xe054
      @Xe054 10 месяцев назад +3

      ​@@ChillAutosthanks, this is the kind of thing that people never mention when a hot new technology comes out.

  • @BattleMercy-uf2zy
    @BattleMercy-uf2zy 8 месяцев назад

    15:44 Based.

  • @xBiggs
    @xBiggs 10 месяцев назад +1

    I use Prisma a lot and have never had any problems

  • @Yupppi
    @Yupppi 4 месяца назад

    Talking about lazy load, why does C++ endlessly yap about "no cost abstractions, you only pay for what you use" and then #include for some single method like printing or one algorithm blasts your code with every single feature from the standard library. You need like a single method from 10 different libraries and suddenly you have 10 full libraries in your short code.

  • @Nickname863
    @Nickname863 10 месяцев назад +1

    As having tried to build (and failed to do so) many c++ projects that use vcpkg in the last few days. I now understand why c++ isn't the dependency hell that javascript can be at times. Every single dependency in c++ is a big pain factor. Not that relevant to the video but i heard the word dependency and needed to vent my frustration.

    • @misterchief5378
      @misterchief5378 10 месяцев назад

      So, by making the integration of each package something that takes attention and lots of effort, c++ without package managers avoids dependency hell?

    • @Nickname863
      @Nickname863 10 месяцев назад

      @@misterchief5378 It is a different kind of hell. But there is no left pad :P

    • @indiesigi7807
      @indiesigi7807 7 месяцев назад

      I mostly just need ssl and mariadb the rest is usually up to me to implement and if i need anything else i can build and link it cause everything is a c lib anyway. Those libs are almost always in my systems package manager. I'm not waiting on some proprietary package manager to get locked into.

  • @austincodes
    @austincodes 10 месяцев назад

    Everyone knows Jason is super fast

  • @therealestsnake
    @therealestsnake 10 месяцев назад +1

    Yeah, I don't think I'm going to ever look at Prisma. These graphs look cool and all, but let's just keep it simple, with a simple DB. Why use json? Weird protocol...

  • @Dev-Siri
    @Dev-Siri 10 месяцев назад

    "Ru$t"

  • @UGPepe
    @UGPepe 10 месяцев назад +4

    these web "technologies" are from the future when the plot of Idiocracy takes place

  • @SimonBuchanNz
    @SimonBuchanNz 10 месяцев назад

    JSON wire protocol is probably about avoiding JIT time? AWS lambda has spectacularly terrible CPU, to the point that i could absolutely expect 1MB of source could take 1s to start.

  • @MahbuburRahman-uc7np
    @MahbuburRahman-uc7np 10 месяцев назад +4

    Used Prisma on an internal project at work with SQL server that had about 100,000 records.
    Table Schema looked something like this:
    1. Table A -> Table B -> Table C (arrow means one two many realtionship)
    One of the queries required that with Select * From Table A we load all realted Table B and Table C rows as well. Its a three table join.
    Running a simple FindMany to get all Table A rows that was created in the last month would simply fail with too many parameter exception.
    Our FIX:
    Moved to .Net Core and never had to look back. All the queries ran just fine, though not fast just becasue how many rows we were pulling in a single query.
    TLDR, Prisma is only good for small projects not production ready IMO.

    • @Pandazaar
      @Pandazaar 10 месяцев назад +4

      prisma is production ready for years already lol

    • @electrolyteorb
      @electrolyteorb 6 месяцев назад

      ​@@Pandazaarproduction ready without JOINs

  • @bartek...
    @bartek... 10 месяцев назад +2

    Is that another first comment?

  • @thundergabriel
    @thundergabriel 10 месяцев назад

    MORTALS: 🔱Use Graph DB like Neo4j and SHUT UP 🤫

  • @jesper.ordrup
    @jesper.ordrup 10 месяцев назад

    Prisma needs to solve the lack of true join. I suggest they open source the specific database drivers to allow more eyes/more experts/use communities knowledge.

  • @electrolyteorb
    @electrolyteorb 10 месяцев назад +1

    Prisma is Sht

  • @CuteTechGuy
    @CuteTechGuy 10 месяцев назад

    Third...

  • @khazixfangirl6087
    @khazixfangirl6087 10 месяцев назад +2

    Hi I'm a comment

  • @raghavgohil2004
    @raghavgohil2004 10 месяцев назад

    FIrst

  • @KhauTek
    @KhauTek 10 месяцев назад

    first comment

  • @greendsnow
    @greendsnow 10 месяцев назад +2

    Drizzle is still better.

  • @FeLiNe418
    @FeLiNe418 10 месяцев назад

    Just use spring boot

    • @dacam29
      @dacam29 10 месяцев назад

      Spring Bootstrap?