|
|
|
|
|
by mvitorino
3725 days ago
|
|
The problem is that most uuids are generated in a way that, when sorted alphabetically as strings, would have a random order. Example:
t0: 7458e3a9-716b-4352-b2e4-b5b67d0c089b
t1: 4d8d753c-1777-439d-8725-b093b1bd8430 Using this as a PK in any relational database will mean the rows are stored in the clustered index order, which causes extreme fragmentation because the db engine constantly has to find "holes" in the data pages to insert more recent records instead of adding those at the bottom of the table as would happen with any continuously increasing key. |
|
UUID key is a problem only if your main query is a range query on the PK of a clustered indexed table. If your main query is a range query, you should pick something that can be sorted in the range anyway.