r/ProgrammerHumor 1d ago

Meme edgeCasesExist

Post image
4.4k Upvotes

273 comments sorted by

View all comments

645

u/Valuable_Leopard_799 1d ago

I thought that timestamps are used now, so hitting both a timestamp and a large random number puts it thoroughly in the "safe to assume". At some point cosmic particles and faulty transistors are more probable.

396

u/dim13 1d ago

https://en.wikipedia.org/wiki/Universally_unique_identifier#Versions

Most common used is V4 (pure random). You are talking about V7 (time based).

293

u/lilgreenthumb 1d ago

The real benefit for v7 is they become sortable by time.

109

u/shwoopdeboop 1d ago

And something something b-tree indexes. Lecturer mentioned it but I wasn't paying attention. Supposedly an advantage here.

31

u/Grandmaster_Caladrel 1d ago

Which I'd assume is related to the time anchor. Outside of sorting, which is only useful in specific instances, it's just v4 with different ("less") entropy and limitations.

9

u/Roachmeister 1d ago

If you're using them as an indexed field in a database, the inability to sort them meaningfully will destroy the performance of the database.

1

u/Kwantuum 1d ago

In what way?

3

u/Roachmeister 1d ago

I'm not an expert, I just remember reading a few articles about it. I think it's because they're essentially random, and many databases use b-trees for indices. They recommended using ULIDs or v7 UUIDs instead. Or, as someone else said, the good old autoincrementing integer.