NEW
Also known as: Universally Unique Identifier
A 128-bit globally unique identifier used to label entities consistently across distributed systems.
DESCRIPTION
UUID is a 128-bit identifier designed to be unique without a central authority, enabling safe merging of data from distributed systems. Standardized by IETF (RFC 4122/9562), versions include time-based, name-based, and random approaches. It is commonly used for database surrogate keys, event IDs, object references, and message correlation. Native support exists in many databases and languages, with storage typically as 16-byte binary or 36-character strings. While collision probabilities are negligible in practice, indexing and random distribution can affect query performance. Security-sensitive contexts should avoid exposing UUIDs if they convey timing or MAC information (v1). Newer alternatives like ULID improve sortability while preserving uniqueness.
ALTERNATIVE DEFINITIONS
IETF RFC 4122
A UUID is a 128-bit identifier used to uniquely identify information in computer systems.
Defines 128-bit format, generation versions, and the UUID URN namespace.
Microsoft Learn
A GUID is a 128-bit integer that can be used across all computers and networks wherever a unique identifier is required.
Emphasizes global uniqueness and practical use in software systems.
PostgreSQL
The data type uuid stores Universally Unique Identifiers (UUID) as defined by RFC 4122, a 128-bit quantity.
Highlights native database type alignment with the RFC specification.
RELATED TERMS
Surrogate Key Primary Key Composite Key Snowflake ID Hashing Namespace RFC 4122 Index Idempotency
COMPETING TERMS
ULID GUID
KNOWLEDGE AREAS
Data Modeling Data Engineering Software Engineering Data Management
TARGET AUDIENCE
Data Engineer Software Developer Data Architect Data Modeler MLOps Engineer
EXTERNAL SOURCES
- Wikipedia - Universally unique identifier
- IETF - Canonical UUID specification
- Python - Python uuid module documentation
- PostgreSQL - Database UUID type details
TOP QUESTIONS
Why use UUID for identifiers instead of auto-incrementing IDs?
UUIDs avoid central coordination and merge conflicts across distributed systems. They enable offline creation and reduce coupling to a single database. The tradeoff is larger size and random index locality.
Category: Relevancy
What are the main UUID versions and when to use them?
Version 1 is time-based, v3 and v5 are name-based (hash), and v4 is random. v4 is common for privacy, while v1 aids temporal ordering but can leak timing or MAC information.
Category: Requirements
How likely are UUID collisions in practice?
Collisions are astronomically unlikely for v4 UUIDs given 122 bits of randomness. In practical systems, collision probability is negligible when implemented correctly.
Category: Misunderstanding
How should UUIDs be stored in databases?
Store as 16-byte binary for efficiency or as canonical 36-character strings for readability. Use suitable indexes and consider sequential-friendly variants to improve write performance.
Category: BestPractices
Is UUID v1 safe to expose publicly?
No. UUID v1 can reveal generation time and potentially MAC-based node information. Prefer v4 or use v1-derivatives that randomize node identifiers for privacy.
Category: Risks
How do UUIDs impact database index performance?
Randomly distributed UUIDs reduce locality, increasing index fragmentation and page splits. Strategies include clustering, randomized but partially ordered IDs, or write-optimized storage.
Category: Performance
What is a modern alternative to UUID?
ULID provides lexicographically sortable 128-bit identifiers combining time and randomness. It improves index locality while keeping low collision probabilities.
Category: Alternatives
Can UUIDs be used as natural keys?
UUIDs are surrogate keys, not natural keys. They uniquely identify records independent of business meaning, easing system integration and change tolerance.
Category: Misunderstanding
How are UUIDs generated securely?
Use cryptographically secure random sources for v4, and approved hash functions for name-based versions. Avoid custom generators unless rigorously reviewed.
Category: Security