Auto increment vs UUID

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • In "Auto increment vs UUID" I share some insights on these two record id strategies.

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

  • @nicolasrepiquet1166
    @nicolasrepiquet1166 6 лет назад +27

    Nice video. Another advantage of UUIDs over auto increment ids is that you can add related objects in one go. Take for example Ticket and TicketLines : with auto increment ids, you first insert a Ticket, fetch the inserted id and then insert the TicketLines. With UUID you can do it in one batch as the Ticket id is generated client side, saving one roundtrip to the database server.

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

      You can use a CTE for that, and solve parent/child problems, no need for a UUID. The performance of UUIDs is quite bad for many reasons. Also, there is the option of having a natural primary key, and the parent/child issues disappear. For example in a database that is about email activity in the table email is the parent primary key. So I try to insert, do an on conflict do nothing (searching for it will be a performance error), and insert the child records. You truly need to be doing something with pretty intensive inserts or something you have no control of like a system with producers and consumers and the producers are partners).

  • @alirabee7649
    @alirabee7649 5 месяцев назад

    Thank you , for the AHA moment

  • @terjemah_alquran
    @terjemah_alquran 4 года назад +2

    thank you. your explanation make me understand why should i use UUID. have a great DAY!!!

  • @sotem3608
    @sotem3608 5 лет назад +6

    I really liked your video, it was interesting to learn about the concept of Auto vs. UUID.
    Really liked the on-the-walk style XD could watch some environment while watching, like taking a actual virtual walk with you =D.

    • @FredrikChristenson
      @FredrikChristenson  5 лет назад +1

      Glad to hear it m8, making these videos is a hobby of mine where I just share some thoughts on things so the casual setting suits me perfectly.
      Have a great day and thank you so much for watching!

  • @dmytromoroz4451
    @dmytromoroz4451 3 года назад +1

    Straight to the point explanation. Thanks a lot!

  • @adeyinkaadefolurin9653
    @adeyinkaadefolurin9653 5 лет назад +4

    I do not know how you did it, but I literally just had a "ha-ha" moment. 👍

  • @nn-hs6ho
    @nn-hs6ho 3 года назад

    Glad to know i wasn't the only one debating this in my head... in 2021.

  • @Antassium
    @Antassium Год назад

    Thanks for your great explanation! ❤

  • @RameshKumar-ng3nf
    @RameshKumar-ng3nf 2 года назад

    Awesome Bro. So clearly explained . Well understood by me. Many thanks for sharing. 🙏🙏

  • @nn-hs6ho
    @nn-hs6ho 3 года назад

    You are timeless bro.

  • @jitendraruley
    @jitendraruley 2 года назад

    Nicely explained. Thanks! :)

  • @nasserchafi5391
    @nasserchafi5391 4 года назад

    cool , new conpect in mind thank you.. i was reading a post about generation stratrgies and they mention this UUID i was like what the heck are they talking about and you made it claire for me.. cheers

  • @aidata0007
    @aidata0007 4 года назад +1

    A good insight on this topic. Btw i noticed something in the video, why so many Volvos out there??

  • @Metachief_X
    @Metachief_X 3 года назад

    ty, great explanation!

  • @RockTheCage55
    @RockTheCage55 11 месяцев назад

    UUID great for programmers but horrible for databases. Will cause page splits in indexes (B+ trees)

  • @andymounthood
    @andymounthood Год назад

    I'm just learning coding now, so far just as a hobby but I'm considering a career as a developer or even a SQL developer. One thing I'm curious about at this stage is merging databases. Isn't this part of data warehousing? I've read that UUID's can greatly slow CRUD operations, but I expect they'd be needed in these situations. So, I'm thinking of using UUID's in some of my coding projects not because I think I would use them in most situations, but just so I can experiment with database merging, migration and maybe small-scale warehousing.

    • @dmitrikonnov922
      @dmitrikonnov922 Год назад

      UUID definitely impairs the performance of DBs with InnoDB engine, esp. under high load, this is what I'm certain about.

  • @gabrielcorrea730
    @gabrielcorrea730 2 года назад

    Can you make a new video about this but nano id vs UUID?

  • @chris_sndw
    @chris_sndw 4 года назад

    I'm using them to generate unique download urls :)

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

    1. They could be necessary if you have a single database but many producers of data, many of them partners and you need the absolute best insert performance and the select and group performance is not that important. I know he knows this but don't want to do a 50-minute video.
    2. Having many databases, or a distributed database is a case. But if you are really under control you can add a prefix to the autoincrement. UUIDs trash your indexes and they are 128 bit numbers in a world full of 64-bit computers. So every single comparison requires either the vector union or a little program.
    3. So avoid UUIDs as much as possible until you truly master them, but they are a blessing for consumer-producer distributed installations.
    4. They are also useful when you have a dynamic system, that breaks the "prefix" solution. or requires an authority to generate the prefixes when the instance is launched.
    5. Many of the indexing nightmares of the UUIDs will be solved with the implementation of the next-generation UUID that contains a time component. The indexes are going to perform both in terms of query and maintenance.

  • @igNights77
    @igNights77 3 года назад +1

    Why don't you give an ID to each database using auto-increment?

  • @tanzimchowdhury320
    @tanzimchowdhury320 Год назад

    Aha!

  • @boot-strapper
    @boot-strapper 3 года назад

    Sadly uuids have fairly large performance hit. Plus they take a ton more space. I guess its just a cost people have to live with..

  • @xenon4602
    @xenon4602 4 года назад

    Walking down the street no none to hang with so lets make a video about programming

  • @kwameasiago6436
    @kwameasiago6436 5 лет назад

    aha

  • @RickTheClipper
    @RickTheClipper 9 дней назад

    A guy crossing streets at red is not a good teacher

  • @owensoft
    @owensoft 6 лет назад +4

    Distributed systems are a edge case problem that is not universal to programming. UUIDs are more trouble than they are worth. If you spend all your time worrying about how complicated your program is GOING TO BE you most likely will never reach any level of complexity because you are doing pre-optimizations that affect your current growth..

    • @Cognitoman
      @Cognitoman 3 года назад

      very cold comment. Anyways, aren't they slow for indexing as well when compared to normal auto increment keys?

    • @owensoft
      @owensoft 3 года назад

      @@Cognitoman they are a few disadvantages and even more warm comments.

    • @Cognitoman
      @Cognitoman 3 года назад

      @@owensoft lol I have no idea why I said "very cold comment"

    • @prerakhere
      @prerakhere 3 месяца назад

      @@Cognitoman good luck on indexing in distributed databases

  • @doktoren99
    @doktoren99 5 лет назад

    Nicely explained. Thanks! :)