Unexpected downsides of UUID keys in PostgreSQL

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • ksuid

    K-Sortable Globally Unique IDs

  • If size isn't an issue it seems so. I know of one implementation that uses wall clock to get a "close enough" sorting https://github.com/segmentio/ksuid

  • deterministic-guid-generator

    Create a deterministic GUID based on namespace Guid, a string and an optional version.

  • Tbh. I love UUID's.

    The next thing i prefer is Deterministic UUID's,

    eg. DeterministicGuid.Create(tenantNamespace, "my-tenant-name");

    Note: https://github.com/Informatievlaanderen/deterministic-guid-g... for dotnet.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • Tbh. I love UUID's.

    The next thing i prefer is Deterministic UUID's,

    eg. DeterministicGuid.Create(tenantNamespace, "my-tenant-name");

    Note: https://github.com/Informatievlaanderen/deterministic-guid-g... for dotnet.

  • flow

    🌊 Continuously synchronize the systems where your data lives, to the systems where you _want_ it to live, with Estuary Flow. 🌊 (by estuary)

  • We use a macaddr8 that embeds a wall-clock timestamp (so they're ascending order, achieving data locality) with some additional randomness. It's worked really well for us:

    https://github.com/estuary/flow/blob/master/supabase/migrati...

    we use macaddr8 instead of bigint, because it has a postgres serialization / JSON encoding which lossless-ly round-trips with browsers and it works well with PostgREST. The same CANNOT be said for bigint, which is a huge footgun.

  • typeid

    Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

  • The stated downsides come from poor data locality when using mostly random UUIDs; but you can keep most of the benefits of a globally unique identifier, and retain locality, by using UUIDv7.

    At jetpack.io we've been doing exactly that via TypeIDs: https://github.com/jetpack-io/typeid and there's a PostgresSQL implementation available. TypeIDs are UUIDv7 with additional type information, so you also get type-safety in your IDs.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts