Deterministic UUID v5 generation with namespaces and separators to avoid collisions

UUID v5 as a Primary Key in PostgreSQL: when business keys stop being unique (and how to avoid collisions)

Summary I was generating deterministic UUID v5 primary keys from business keys. It worked well—until subtle but serious collision risks appeared: Ambiguous concatenation (ab + cd vs a + bcd) Cross-table collisions (different tables, same business values → same UUID) This post presents a clean, modular solution using explicit separators and namespace scoping, and explores the harder problem of multi-source ingestion. ⚙️ Context & Problem In data platforms and ETL systems, business keys are often the only stable identifiers available (for example, composite natural keys). To ensure idempotency and simplify upserts and deduplication, a common pattern is: ...

January 18, 2026 · 6 min · Frederico Gago