Home / Companies / PlanetScale / Blog / Post Details
Content Deep Dive

The problem with using a UUID primary key in MySQL

Blog post from PlanetScale

Post Details
Company
Date Published
Author
Brian Morrison II
Word Count
1,776
Language
English
Hacker News Points
5
Summary

Universally Unique Identifiers (UUIDs) are designed for generating unique IDs across systems without knowledge of other systems, making them useful in distributed architectures. However, using UUIDs as primary keys in MySQL can hurt database performance due to insertion overhead and increased storage utilization. To mitigate these issues, consider using the binary data type for storing UUIDs, choosing an ordered UUID variant, utilizing built-in MySQL functions like `uuid_to_bin`, or exploring alternate ID types such as Snowflake IDs, ULIDs, or NanoIDs.