logoalt Hacker News

majorchordlast Monday at 3:01 PM2 repliesview on HN

> You can argue that, but then what is its purpose? Why should anyone care about the creation date of a by-design completely arbitrary thing?

Pretty sure sorting and filtering them by date/time range in a database is the purpose.


Replies

miroljublast Monday at 3:24 PM

If you need sorting and filtering by date, just add a timestamp to your table instead of misusing an Id column for that.

show 3 replies
dparklast Monday at 6:42 PM

That is absolutely not the purpose. The specific purpose of uuidv7 is to optimize for B-Tree characteristics, not so you can craft queries based on the IDs being sequential.

This assumption that you can query across IDs is exactly what is being cautioned against. As soon as you do that, you are talking a dependency on an implementation detail. The contract is that you get a UUID, not that you get 48 bits of timestamp. There are 8 different UUID types and even v7 has more than one variant.

show 1 reply