I'm building an app aimed to store lots of records (millions) and trying to find a best way to store records identifiers that is publicly accessible from the web (record URL).
I'd like to get:
- Random, probably unique, unpredictable IDs that is reasonably short and possible to use in an URL, meaning UUID will not suit as it is too long.
- Best performance from database and reduce storage space.
- Avoid creating auto increment id with the only purpose to use it as a PRIMARY key.
- ...Avoid future replication issues?
My first thought was to generate a random string like
4r5psPxuRw and use it as a primary key (CHAR(10)). But in this case index will be 30 bytes per record and I assume that with the large amount of records INSERT performance will suffer.
Now I came to a random numeric string, for example 16 digits from 1 to 9, and store it as BIGINT(16).
Is this a good way to achieve security, speed and reduce number of surrogate keys? Am I missing something?