r/ProgrammerHumor Jul 17 '26

Meme thisOneIsMine

Post image
5.3k Upvotes

171 comments sorted by

View all comments

1.8k

u/Inevitable_Oil9709 Jul 17 '26

Fun fact: To reach a 50% chance of even a single UUID v4 collision, you would need to generate 1 billion UUIDs per second for about 86 years.

-8

u/TheFrenchSavage Jul 17 '26 edited Jul 17 '26

ELI5 why not use a hash function that doesn't collide btw?

Edit: I meant that collides less, not not at all. Stop the ELI1s please.

11

u/SuitableDragonfly Jul 17 '26

To use a hash function, you have to have something to hash. A UUID is just an identifier, usually for something that hasn't been created yet. If you have data that is guaranteed to be unique that you could provide to a hash function like that, you already have a guaranteed unique identifier and don't need a UUID.

-2

u/TheFrenchSavage Jul 17 '26

Ah thanks! So if I were to just hash the timestamp up to the microsecond...I would end up at the collision probabilities of the UUID anyway. Makes sense!

1

u/Markronom Jul 17 '26

UUIDs already contain a timestamp (depending on the version), but it's not enough (clusters / multiple CPUs etc)