spec icon indicating copy to clipboard operation
spec copied to clipboard

would ulid be better then snowflake id?

Open VincentRPS opened this issue 3 years ago • 3 comments

would ulid be better/more unique than a twitter snowflake and why?

VincentRPS avatar Mar 18 '22 09:03 VincentRPS

I don't really know anything about this (as I'm just discovering ULIDs myself) but it seems to me that snowflakes require a machine ID, which has the same problems as UUID v1 and v2. If the machine ID isn't universally unique, then the resulting snowflake won't be either.

mholt avatar Oct 05 '22 03:10 mholt

A little late to the party, but...

  • A snowflake indeed requires some sort of machine/node id for each generator, while ULID doesn't.
  • A snowflake id is 8 bytes (a long datatype in most languages), which can be convenient. ULID is 16 bytes, or 26 chars, so it can store many more values while still offering the same general promise of monotonicity, albeit not always 100% accurate if two ids are generated within the same millisecond of each other, but that usually doesn't matter in practice.

andrewlalis avatar Jan 27 '23 21:01 andrewlalis

A little late to the party, but...

  • A snowflake indeed requires some sort of machine/node id for each generator, while ULID doesn't.
  • A snowflake id is 8 bytes (a long datatype in most languages), which can be convenient. ULID is 16 bytes, or 26 chars, so it can store many more values while still offering the same general promise of monotonicity, albeit not always 100% accurate if two ids are generated within the same millisecond of each other, but that usually doesn't matter in practice.

It seems that snowflake id may be more ideal then, even if it requires some sort of machine/node id that could always just be set to the name of the thread your using in your language or something. Or well as long as you don't care about having to use BigInts or Longs everywhere instead of normal integers

VincentRPS avatar Jan 28 '23 00:01 VincentRPS