The Developer's Guide to UUIDs: Versions, Use Cases, and Best Practices
A Universally Unique Identifier (UUID) is a 128-bit number used to identify information without requiring a central coordinating authority. UUIDs solve a fundamental distributed systems problem: generating unique identifiers across multiple machines without communication between them.
UUID Version 1 combines a timestamp with MAC address (leaks info but guarantees uniqueness). Version 4 is entirely random with 122 bits of randomness, making collisions statistically impossible for practical purposes. You would need 2.71 quintillion UUIDs for a 50% collision probability. Version 7 (newest, RFC 9562) combines a Unix timestamp with randomness, providing time-ordering for database performance without leaking machine identity.
Database considerations: Random v4 UUIDs cause B-tree index fragmentation and can make inserts 5-10x slower on large tables. Solutions include using v7 for sequential ordering, binary storage (BINARY(16) saves 56% space vs CHAR(36)), or a composite approach with auto-increment internally and UUID externally. Choose UUIDs for distributed systems, public-facing IDs, and cross-database merges. Choose auto-increment for single databases where maximum performance matters. Use our UUID Generator to create v1, v4, and v7 UUIDs for your applications.