3 ms·
I've been doing something that includes a type character as the first character - followed by 11 random base58 digits. This allows > 2^64 possible ids and a typ
by mattbillenstein 2y ago
I've been doing something that includes a type character as the first character - followed by 11 random base58 digits. This allows > 2^64 possible ids and a type in ~12 bytes. I occasionally wish they were ordered, but most of my tables usually have a 'created_at' field anyway should ordering matter.
I feel like uuid / ulid are just overkill for most situations - and they're long and kinda ugly imo.
- cbsmith 2y agoIsn't that basically a type 4 UUID that you truncated the last 4 bytes from?
- mattbillenstein 2y agoThe encoding is completely different? And given that encoding I don't go to any great means to store them as a special type in the db - just text. uuid being hexidecimal, databases often want to store them as binary since that's half the bytes...
- cbsmith 2y agoYou could encode UUIDs as base58, though I'm with you that that doesn't seem to make a lot of sense.