bigint for a primary key in Postgres.
performance wise better, but this only really matters for millions of rows.
but i add a prefixed nanoid, e.g. “user_<nanoid>” to expose as a public id instead of the bigint.
int is enough to start with.
UUID is good if it is a distributed system or serial ID should not be exposed.
Bear in mind that UUID is a tad slower than Serial Int and takes more space (16 bytes). Indexes on UUID are a tad slower as well.
I have written a module named QuantumId (not public yet). It is sortable, incremental
and collision free.
A bit shift map makes the output unpredictable for consumers. So it has a byte (for the db) and a string representation (for public use)