mardi 1 août 2023

DB Index-friendly way of generating random codes?

I need to generate 8-digit codes serving as identifiers and store them in the (SQL) database. Now if I want to avoid straight sequence like 000001, 000002 etc. thus I need some random generator.

Yet by random value, to ensure uniqueness I need to compare new one with all already stored. This obviously will cost me more and more time as the number of codes growths.

Is there a way to have pseudo random patterns which will be index-friendly so they could be compared in limited time?




Aucun commentaire:

Enregistrer un commentaire