/plushcap/analysis/planetscale/the-problem-with-using-a-uuid-primary-key-in-mysql

The problem with using a UUID primary key in MySQL

What's this blog post about?

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.

Company
PlanetScale

Date published
March 19, 2024

Author(s)
Brian Morrison II

Word count
1776

Language
English

Hacker News points
5


By Matt Makai. 2021-2024.