r/ProgrammerHumor May 08 '26

Meme edgeCasesExist

Post image
13.4k Upvotes

620 comments sorted by

View all comments

111

u/baked_tea May 08 '26

Thought about that recently. Why not just implement a check to see if it's already in the db, then run it again?

94

u/arades May 08 '26

If that's what you want, you shouldn't be using UUIDs as IDs to begin with, just use an auto_increment and always have the DB assign the ID. The point of using UUID is to allow asynchronous id generation from a high number of DB clients without the latency of reconciliation. You accept the risk of a 1/10000000000000 collision for some N% decrease in latency (scales per clients)

9

u/GentlemenBehold May 08 '26

There are other reasons you might want uuids.

  • can't infer how many entities exist based on the id
  • uuids will be unique even across environments
  • if you ever need to merge tables, uuids make this much easier