Note: I have already read through older questions like What is the best format for a customer number, order number? , however my question is a little more specific.
Generating pseudo-random numbers encounter the "birthday problem" before long. For example, if I am using a 27-bit field for my order number, after 15000 entries, the chances of collision increase to 50%.
I am wondering whether large ecommerce businesses like Amazon generates its order number in any other way - for example :
- pre-generate the entire set and pick from them randomly (a few hundred GB of database)
- Use lexicographical "next_permutation" starting from a particular seed number
- MD5 or SHA-1 hash of the date, user-id, etc parameters, truncated to 14 digits
- etc
All I want is a non-repeating integer (doesnt need to be very random except to obfuscate total number of orders) of a certain width. Any ideas on how this can be achieved ?