I'm thinking to use (on PostgreSQL v13) an UUID type (with uuid_generate_v4()
) for my tables with high traffic, and the others with a Text type (as primary key) by using an auto-generated similar to crypt(now()::text, gen_salt('des'))
(short UUID?).
What concerns are there respect to use this short-UUID-like type? Can it be considered a good practice? If not, what suggestions do you propose?
Let's suppose to have a table with various foreign keys (FK), every FK is an UUID type, then when we open that table we'll see a long sheet stretching horizontally, or when we make a API call returning a list of objects with their IDs, well it is not cool.
I was checking some API calls available on Net, and they use some short-UUID-like type with a fixed length of 10 chars, so I was thinking, how do they get that result without getting any conflicts? What about its performance? etc.
uuid
for all of them? Btw: Postgres 13 has a built-ingen_random_uuid()
function, no need to install an extension to getuuid_generate_v4()
any more. I would never choose a data type over another, just because one has a more visually appealing representation.