jeudi 21 mai 2020

Database design pk autoincrement vs uuid, do not want to expose PK in url

I am building a website that has some features similar to that of Instagram (i.e if you click on some post, you get: https://www.instagram.com/p/[some_hash]/. How does instagram do this? Do they hash the primary key ID? Do they use a UUID?

I have done a lot of reading regarding auto incrementing PKs vs UUID PKs and am honestly still not sure what would be the best for this use case.

It is my understanding that if I were to use incrementing PKs, I could store a hashed value of that ID and use that in the URL. However, if I were to use a UUID, it could potentially make scaling much simpler due to the fact that it is extremely likely to be unique. That being said, UUIDs seem to negatively impact Mysql performance and also take 4x the space of a basic INT type and 2x the space of a bigint type.

Any suggestions are appreciated!

Thank you

Aucun commentaire:

Enregistrer un commentaire