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?

            01859DB9-6B25-D56C-588A-F72D574F5A18
            01859DBA-7172-6F88-78CE-52F5D447B79F
            01859DBA-8F2C-D57A-8ED8-F1519161A51C
            01859DBA-BCDD-F392-6FF9-66A47252644B
            
            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
              F61DCF92-863B-4250-98EA-16E417311539
              F6411104-AA7F-47D9-B4F2-D6A2B96834B5
              A5D25324-E8B6-478F-B626-28ACC7683988
              27A8CB5A-2307-467E-A076-8EF5D7C05ED8
              D1F034B1-C2B2-43C7-B4C1-DE7550E86FEF
              
              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.