DEV Community

Discussion on: Generate a unique random code to store in DB

Collapse
 
mmj profile image
MMJ

No a bad idea at all. Could be useful when you don't have to stick to a fixed lentgh for other reasons.
Can't think about downsides about your suggestion offhand.
Maybe it will work faster than with fixed lenght at the beginning, with few records, but slower at certain point?

Collapse
 
antondachauer profile image
Anton Dachauer

I don't know, which variant is faster overall. Depending on the possibilities and the technical infrastructure, it makes sense to store the used keys in a mongodb, which would be faster in storing key-value-pairs. Or elasticsearch or any other NoSQL-Databse.