1. 27
  1. 4

    One of the downsides—potentially—is that each ULID leaks the information of when it was created. I mean, this is obviously one of the big selling points of ULIDs, but there might be situations where it’s undesirable.

    1. 3

      Good point. I added it to my list of downsides. Thanks!

      1. 2

        I came here to say this… The main reason to use random UUIDs is that they are meaningless identifiers and they do not reveal anything else (increment counts, creation dates, node where entity was created, whether one entity was created before/after the other one, entity types, categories, tags or other metadata).

        There might be a reason to use ULID sometimes, but when designing a system and identifier scheme, I would be rather a bit paranoid by default and do not encode any other data into identifier unless I have a really good reason to do so.

        1. 4

          Nit: only UUIDv4 is random. Versions 1 and 2 definitely leak information, since they encode a timestamp and a MAC address of the node generating the id.

      2. 3

        Would you choose UUID v6/v7 if they were more stable and prevalent do you think? Or does the base32 encoding of ULIDs play a siginifics role in preferring them?

        1. 1

          Yeah, maybe, although I do think you still need a better encoding for URLs and such.

          1. 1

            Well, canonical hex encoding isn’t enforced in any way. You can use whatever encoding format you want.

        2. 2

          Creator of https://www.ulidtools.com here - nice site! ULIDS ftw.

          1. 2

            Are you sure that these strings are UUIDv4?

            1. 2

              For anyone who’s wondering what makes them not UUIDv4s, I guess it’s because the the first part, 01859DB9-, does not look very random. A UUIDv4 however is completely random, like:

              $ for x in $(seq 5); do uuidgen; done
              1. 7

                This issue is that the version/variant aren’t correct for UUIDv4. You can see when you decode them: https://www.uuidtools.com/decode

                1. 1

                  Thanks! Didn’t knew that the version is encoded in the UUID.

            2. 1

              Wow, that’s great! Is it open source?

            3. 2

              One downside of ULID and UUID v7 is that you also can get bottlenecked in the database, because multiple entries may be right beside each other (many entries with at the same time). Fully random IDs may be on very different memory pages (or the disk backed equivalent), so the concurrency can be better.

              Still I personally prefer v7, because for my workload the random memory layout of UUID v4 would slow me down.

              1. 5

                For anyone curious, this percona article discusses the performance implications of using UUIDs as row keys.

                1. 1

                  If you are using random UUID values as primary keys, your performance is limited by the amount of memory you can afford

                  Their performance benchmark is definitely something

              2. 1

                Two other approaches I’ve considered in the past are XID and CUID - I eventually settled on XID for a project.