I'm new to databases and have been considering using a UUID as the primary key in my project, but I read some things which made me interested to learn more about the performance.
Currently, I am using the uuid data type and the default value is set to gen_random_uuid().
First of all, I was wondering: would UUIDs be less performant as a primary key?
If so...
- Are there any tips to optimize it, e.g. would it help if the PK was sequential, but another field contained a UUID, specifically for public exposure?
- Are there any similar alternatives which may be more performant?
(I'm not working with data of any considerable scale just yet; it's more of a theoretical question.)
AUTOINCREMENTin Postgres