cockroachdb / cockroachdb/cockroach
Add support for uuid7
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Is your feature request related to a problem? Please describe.**
In order to have unique IDs that are sortable and do not expose machine's information (MAC address on uuid 1), it would be nice to support uuid v7 in the uuid_generate_* functions.
**Describe the solution you'd like**
A new function `uuid_generate_v7` which conforms with the [draft spec](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format)
**Describe alternatives you've considered**
One can generate that uuid outside of cockroachdb and use in an uuid field, but there is no way to add as default for a column.
**Possible concerns**
UUIDv7 is monotonically increasing, so using it as the key for an index can lead to hotspots. All rows that are inserted will be added to the same range of the index. Refer to: https://www.cockroachlabs.com/docs/stable/performance-best-practices-overview#unique-id-best-practices
Jira issue: CRDB-24758
Epic CRDB-60811
Contributor guide
Research direction
Start by locating the existing uuid_generate_* entry points and their tests in CockroachDB, then read the linked draft UUIDv7 specification. Define completion as a new uuid_generate_v7 function that conforms to the draft and can be used as a column default; verify it with the relevant UUID function tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100