ulid is a time-based, ordered implementation of UUID generation. See https://github.com/oklog/ulid
Some users have reported smaller data sizes using ulid-derived UUIDs compared to random uuidv4 ids -- potentially due to compression-friendliness of similar keys thanks to being time-based. We potentially could offer a builtin to produce them (though the usual considerations with load distribution time-based keys in some workloads still applies).
How would this be better than unique_rowid() (which is the same idea in 64 bits)?
I think the primary benefit would just be uuid compatibility -- you can switch generation schemes without switching types.
What is the progress on adding ULID?
@robinbraemer, we don't have any immediate plans to work on this. However, we do accept contributions! If you're interested in adding a ULID generator builtin, we would be happy to review it.
See CONTRIBUTING.md for instructions. Code for builtins goes in pkg/sql/sem/builtins.go.
@robinbraemer are you working on this issue OR else I would like to work on it ?
@SyedMuhammadSufyian No, I haven鈥榯 written any code yet. Thanks for taking your time implementing ULID.
@robinbraemer , I am contributing to it.
@robinbraemer @jordanlewis How about giving this configuration in the hands of user , to select the uuid generation scheme ?
AFAIK, @dt meant ULID will not be a new cockroachdb type but instead an additional choice for the user of how to generate a UUID beside the function gen_random_uuid().
As a result an example table could look like this: CREATE TABLE t1 (id UUID PRIMARY KEY DEFAULT gen_ulid(), name STRING);. Note the id column is still of type UUID but is generated by default using the not yet provided ULID function (not sure if the function name will be used).
@robinbraemer I am on it
Any progress with this?
Most helpful comment
AFAIK, @dt meant ULID will not be a new cockroachdb type but instead an additional choice for the user of how to generate a UUID beside the function
gen_random_uuid().As a result an example table could look like this:
CREATE TABLE t1 (id UUID PRIMARY KEY DEFAULT gen_ulid(), name STRING);. Note the id column is still of type UUID but is generated by default using the not yet provided ULID function (not sure if the function name will be used).