Live data from Hacker News

Goodbye integers, hello UUIDv7

buildkite.com

11–20 of 376 posts

Re: Goodbye integers, hello UUIDv7

#11
post #5

And you can use it today with Postgres uuid type. Postgres doesn’t care what you store in it as long as it has the correct length. So you can generate a uuidv7 and store it natively

Wouldn’t the index types need to be updated to support ordering on UUIDs?

No, because the ordering is purely byte level which will work perfectly fine here.

Re: Goodbye integers, hello UUIDv7

#13
post #3

I find it interesting that it’s quoted random IDs are bad for performance, because it’s actually better for distributed storage systems because you don’t hotspot on a single node. For example see: https://stackoverflow.com/a/53901549 and https://medium.com/google-cloud/cloud-spanner-choosing-the-r...

UUIDv7: Timestamp up front, random in the back.

Truly, the mullet of unique identifiers.

Re: Goodbye integers, hello UUIDv7

#14
It’s nice for front end state. You post the new entity, the front provides the ID, and as long as you get a 200 you can update your state, or update optimistically and roll it back. You don’t need to wait for the API to figure out what your ID is.

Re: Goodbye integers, hello UUIDv7

#15
post #3

I find it interesting that it’s quoted random IDs are bad for performance, because it’s actually better for distributed storage systems because you don’t hotspot on a single node. For example see: https://stackoverflow.com/a/53901549 and https://medium.com/google-cloud/cloud-spanner-choosing-the-r...

Agree, but the solution is easy peasy with a simple hash function.

(Or just reverse the bits, take the last n, etc)

Re: Goodbye integers, hello UUIDv7

#16
post #3

I find it interesting that it’s quoted random IDs are bad for performance, because it’s actually better for distributed storage systems because you don’t hotspot on a single node. For example see: https://stackoverflow.com/a/53901549 and https://medium.com/google-cloud/cloud-spanner-choosing-the-r...

It's bad for performance if you frequently access large consecutive sets of records.

Re: Goodbye integers, hello UUIDv7

#18
> We use sequential primary keys for efficient indexing, and UUID secondary keys for external use. The upcoming UUIDv7 standard offers the best of both worlds

Unless you consider users being able to extract the generation time from the id to be an issue, of course.

Re: Goodbye integers, hello UUIDv7

#19
post #18

> We use sequential primary keys for efficient indexing, and UUID secondary keys for external use. The upcoming UUIDv7 standard offers the best of both worlds Unless you consider users being able to extract the generation time from the id to be an issue, of course.

I've been seeing a few different vendors do this already. MongoDB's ObjectIds are inherently timestamps (so you can actually generate generic MongoDB IDs to query based on time). There's also Discord's Snowflakes as well. I'm sure there's loads of others. All it tells you is when something was generated, not much else. I do love how MongoDB has it stored in such a way that it is easy to query against. I wonder if any RDBMS' will allow you to query these timestamps as well.

Re: Goodbye integers, hello UUIDv7

#20
Can you take the first portion of the UUIDv7 string, and decode it to figure out the exact date and time that record was created? I'm wondering if there might be security/privacy concerns in some situations if the UUID codes are visible in your app?
Post reply on HN