by BiteCode_dev · 4y ago · 0 comments
- similar characteristics to UUID: same number of bytes, equivalent collision resistance, hard to guess, etc.
- start with a date, is monotonic, and is lexicographically sortable: not only it has great locality but sorting is super easy and most code get it right by default.
- can be created from an existing date or uuid, and exported to a uuid, so there is a migration path.
- you get the creation date for free, which is always nice. As a bonus, you can now use the uuid as a base for dispatching, bracketing, sharding, etc.
Leaking information is not “always nice”. For example using that as an id for a medical record would give you specific information for the date of diagnosis or treatment.
They are always exceptions.
"always nice" is a matter of speaking.
There are very few things that are always true, and I assume reader know that.
Probably just don't take the correction so personally. I think quite often it is the case that a person "corrects" in this manner (remember: this is a public online forum) because they want the thing they say to be visible alongside the thing they responded to.
Not you, but instead the next reader, will read what you wrote and then build their medical/finance/legal application thinking that the availability of additional metadata can't possibly have any downsides. But (perhaps) now that reader will read the response and not make said mistake.
Incorrectly. It's a matter of speaking incorrectly.
They can't lie, so they are perfectly correct.
For reference here is my plpgsql implementation: https://gist.github.com/Sytten/8fa334e8a5de5d49924c794811a80...
They're basically the same, except uuidv7 has a few bits less randomness for UUID fields like version and variant, so I'm sure in 5-10 years the answer will be just use v7, but for the time being, for those use cases I'd stick to ULID.
It allows strict monotonic IDs when you provide it the previously generated ID. The resulting data structure is a Uint8Array making it easy to put into binary structures. Can also be used as a key inside any POJO record.
But ULID exists right now, UUID7 is still in the making.