- What is a UUID?
- UUID stands for Universally Unique Identifier. It is a 128-bit label used in computing to uniquely identify information without central coordination. Formatted as 32 hexadecimal digits in five groups: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. Defined in RFC 4122.
- What is UUID v4?
- UUID version 4 is randomly generated — 122 of its 128 bits are random, with 6 bits used for version and variant indicators. It requires no coordination, no timestamp, and no hardware address, making it ideal for distributed systems. It is the most commonly used UUID version.
- What is the probability of a UUID collision?
- UUID v4 has 2¹²² possible values (approximately 5.3 × 10³⁶). To have a 50% probability of a single collision, you would need to generate about 2.7 × 10¹⁸ UUIDs. At a billion UUIDs per second, that would take 85 years. Practical collision probability is effectively zero.
- What is the difference between UUID and GUID?
- GUID (Globally Unique Identifier) is Microsoft's term for UUID — they are the same thing. Microsoft introduced the term for use in COM/DCOM and Windows APIs. GUIDs follow the RFC 4122 standard and are formatted identically to UUIDs.
- When should I use a UUID instead of an auto-increment ID?
- UUIDs are better when: merging data from multiple databases, creating IDs client-side before a server round-trip, working in distributed/microservice systems where central ID generation is a bottleneck, or when you want IDs that reveal no information about creation order. Auto-increment is more compact and faster for single-database applications.
- What format should I use for UUIDs in a database?
- Most databases offer a native UUID type (PostgreSQL, MySQL 8.0+) which stores 16 bytes more efficiently than a string. If no native type is available, store as CHAR(36) for the standard hyphenated format or CHAR(32)/BINARY(16) for the compact form. Avoid VARCHAR for UUIDs — the length is always fixed.
- Are UUIDs case-sensitive?
- UUID values themselves are case-insensitive (a3bb189e and A3BB189E are the same UUID). However, some systems and databases store or compare them case-sensitively. The RFC 4122 standard recommends outputting lowercase UUIDs, which is the default format in this generator.