Does this small piece of code seem ok? |
Don't forget there are also costs involved in checking. Which is why GUIDs are designed so you don't have the management of repeat number overhead to worry about.
I know it doesn't seem like much of a problem to do a select before hand, but lets say you've got hundreds of thousands of visitors and these unique ids are tied to dynamically generated form inputs which a user could have many of, hundreds if not more, and before they generate a new one the db has to do a check. It could affect performance. Choose a suitably large number random and this would avoid this. Expect of course, for the birthday paradox http://betterexplained.com/articles/unde...y-paradox/ And some more interesting ideas solving the birthday paradox http://getsolid.io/blog/birthday-paradox-coding-solid/ But yes I do understand your point.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
|
Welcome Guest, Not a member yet? Register Sign In |