I saw this after installing the Temporal.io client:
https://github.com/paralleldrive/cuid2<p>What should I use for a startup going after B2B sales?<p>ULIDs or CUID2s for primary keys?<p>I remember seeing Hussein Nasser's Shopify video: https://www.youtube.com/watch?v=f53-Iw_5ucA<p>And it made me switch to using ULIDs instead.<p>I know this may fall into the "premature optimization is the root of all evils" category. But since it's straightforward, what should I do?<p>I've been using ULIDs in distributed systems with no problems so far.
ULIDs are time ordered and CUID2s are random. So your decision should really be based on whether you want ordered IDs are not. Ordering is useful for transactional entities because you tend to operate on recent entities much more than older ones and things like partitioning, indexing become easier, whereas for non-transactional long lived entities, it might not matter much. Some applications don't like to leak time information through their IDs so they choose random IDs.<p>There is also UUIDv7 now which is similar to ULID but UUID compatible and might be a more ubiquitous standard going forward.