Top all-time · #12419
Dave Allie
Personal blog · blog.daveallie.comprogrammingdata
Dave Allie's personal blog at blog.daveallie.com covers programming and data. Since 2022, 6 different Hacker News readers have linked it 6 times, most often “ULIDs and Primary Keys (2022)”. The last post was in 2024, but the archive is still widely read.
Too few sampled comments (4) to say how often HN recommends it.?
Why HN links it
Posts on UUIDs and ULIDs as database primary keys, covering whether ULIDs can be stored as UUIDs, how they relate to UUIDv7, and insert and generation performance in Postgres.
Summarised by Claude from a sample of 4 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.
Most-linked posts?
- ULIDs and Primary Keys (2022)4 people · 4 mentions · first linked 2022-11-22
- /ulid-primary-keys/2 people · 2 mentions · first linked 2024-12-29
What Hacker News says?
You can use ULID and store it as UUID since they are the same size. You can check this article for the details: https://blog.daveallie.com/ulid-primary-keys
Comment linking /ulid-primary-keys
on “Moving Away from UUIDs (2018)”Submitted ULIDs and Primary Keys (2022) as a story · 76 points
HN discussionOk wow this blog post was really illuminating. Thanks for pushing back on my preconceived idea that UUIDv7 is the 'official' version of ULID https://blog.daveallie.com/ulid-primary-keys
Comment linking /ulid-primary-keys
on “The UX of UUIDs”Submitted ULIDs and Primary Keys as a story · 1 points
HN discussionI don't think that's right. They show in the section titled "Generating" that the performance of calling the ULID function from SQL is only very slightly slower. It's the INSERT that performs worse. Generally, inserting sorted values (like sequential integers or in this case, ULIDs) into a B-tree index is much faster than inserting random values. This is because inserted values go into the same, highly packed B-tree…
Comment linking /ulid-primary-keys/
on “Exploring Alternatives to UUIDv4; Enter ULIDs”It's likely a function of the fact that `gen_random_uuid()` is implemented in C [0], and is essentially just reading from `/dev/urandom`, then modifying the variant and version bits. Whereas, assuming they're using something like what was described here [1], that's a lot of function calls within Postgres, which slows it down. As an example, this small function that makes UUIDv4: postgres=# CREATE OR REPLACE FUNCTION…
Comment linking /ulid-primary-keys/
on “Exploring Alternatives to UUIDv4; Enter ULIDs”