Stop Using UUIDv4 in Your Database

How UUIDs can Destroy SQL Database Performance

Daniel Craciun
3 min readMay 16, 2024

Not a Member? Read for FREE here.

a lock shooting energy into a database table field causing the field to grow massive in size
This image has been generated by AI.

One of the most common way to uniquely identify rows in a database is by using UUID fields.

This approach, however, comes with performance caveats that you must be aware of.

In this article, we discuss two performance issues that may arise when using UUIDs as keys in your database tables.

So without further ado… Let’s jump right in!

What are UUIDs?

UUID stands for Universally Unique Identifier.

There are many versions of UUID, but in this article we will consider the most popular one: UUIDv4.

Here is an example of how a UUIDv4 looks like:

<source>

NOTE: Each UUID has the digit 4 in the same position to denote the version.

Problem 1 — Insert Performance

When a new record is inserted into a table, the index associated with the primary key must be updated to maintain optimal query performance.

--

--