HiveBrain v1.2.0
Get Started
← Back to all entries
principlesqlMinor

Impact of using UUIDs with an UNIQUE index vs. PK?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
uniqueimpactuuidswithusingindex

Problem

It's well known how the performance of random UUIDs as PKs in an InnoDB table degrades terribly as it increases in size. Would an UNIQUE index for a non-PK UUID column have the same impact?

UUIDs are Version 4, random, stored as binary(16).

Solution

I guess you are referring to the InnoDB clustered index performance. If I'm not mistaken, the PK is chosen as the clustered index by default, so any other, secondary index containing the UUID column should not suffer from the same problem.

Alternatively, I think you can create the table without declaring the PK at first, in which case MySQL will create an automatic clustered index based on row IDs. You can then alter the table and add the necessary primary key constraint.

Context

StackExchange Database Administrators Q#80403, answer score: 4

Revisions (0)

No revisions yet.