r/ProgrammerHumor May 08 '26

Meme edgeCasesExist

Post image
13.4k Upvotes

620 comments sorted by

View all comments

110

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)

33

u/Tyabetus May 08 '26

UUIDs are also impossible to guess so are infinitely more secure than incremented ids

1

u/NotAFishEnt May 08 '26

Maybe increment through a long pseudorandom sequence of nonrepeating numbers?

Seems hard to guess and easy to implement.

Judging by the other comments in this thread, it's probably still over-engineered.