top | item 40959889

(no title)

robbie-c | 1 year ago

You’ve maybe not had a use case for sortable uuids, so I can provide one:

Columnar databases like Clickhouse don’t have the kind of indices that you’d be used to if you only used OLTP databases like eg Postgres. Instead, you essentially get one index per table, which is the order that things are laid out on disk*

The problem is that you might want 2 access patterns, one for aggregating data within a time range, and another for looking up / joining data by its ID. So which do you use as the index? Timestamp or ID? If the ID is a uuidv4 and you index by ID, your time range queries need to scan the entire table, and vice versa. If the ID is time-sortable (eg uuidv7), this stops being a problem, and you don’t need some kind of workaround*

* it’s a little more complicated than this but that not in a way that affects the example

* eg a projection of your data with a different index

discuss

order

saagarjha|1 year ago

I understand your usecase. I just think it's a horrible hack.

qarl|1 year ago

HEH... yeah. Why does software engineering always go out the window when there appear to be a couple of unused bits?

radarsat1|1 year ago

This is exactly why I'm using ULID with DynamoDB.