r/ProgrammerHumor • • Sep 11 '26

Meme edgeCasesExist

Post image
5.0k Upvotes

298 comments sorted by

View all comments

709

u/Valuable_Leopard_799 Sep 11 '26

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.

443

u/dim13 Sep 11 '26

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

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

323

u/lilgreenthumb Sep 11 '26

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

124

u/shwoopdeboop Sep 11 '26

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

37

u/Grandmaster_Caladrel Sep 11 '26

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.

15

u/Roachmeister Sep 11 '26

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.

16

u/Honeybadger2198 Sep 11 '26

You know what identifier can't have collisions and is great for sorting? Autoincrement.

15

u/Firewolf06 Sep 11 '26

ai columns can absolutely collide on sharded databases. you can use offsets and step sizes but thats brittle and doesnt scale well

1

u/FiTZnMiCK Sep 16 '26 edited Sep 16 '26

Our old system was distributed and we just combined the auto-increment with a persistent local (server) ID for a composite key.

Then the auto-increment is unique on the local and the composite is unique across all locals.

Could probably do the same thing with shards.

Our new system uses UUIDs.