We're designing a table for user entity. The only non-trivial requirement is that there should be a permanent URL to the user entity (for example their profile). There's a lot about int/long vs UUID on the web. But it is still unclear to me.
- Considering the fact that the profile contains private information, it's not a good idea to have a predictable ID embedded in the URL. Am I right?
- To satisfy the first I can have primary key as UUID and embed it in the URL. But there's two question. Should I be worried about the performance penalty of having UUID as primary key in anyway; indexing, inserting, selecting, joining?
Having that said, which one of the following is better (with respect to the above)?
CREATE TABLE users(
pk UUID NOT NULL,
.....
PRIMARY KEY(pk)
);
or
CREATE TABLE users(
pk INT NOT NULL AUTO_INCREMENT,
id UUID NOT NULL,
.....
PRIMARY KEY(pk),
UNIQUE(id)
);