私たちのほとんどは、Amazon のようなサイトから購入すると、乱数のような注文番号または購入番号 (10 ~ 12 桁) を取得することを見てきました。同様に、大規模システム用に一意の ID を生成したいと考えています。それを生成するための最良のアルゴリズムは何ですか?
私が効率的ではない、または大規模システムには適用できないと思ったいくつかの方法
1) Generating string using rand function ( Array.new(12){rand(10)}.join) and checking
whole table whether it is exists. It is time consuming, inefficient and may struck
in infinite loop.
2) Using time-stamp - I think this cannot be used for large scale system because large
no. user can excess system at same time.
3) Combination of 1) & 2) also creates issue as second when it generates same 1)
Auto increment : I don't want to use.