Database Primary Key Length Design Tool
Calculate collision probability with the birthday paradox and design a safe random segment length for primary keys
Character Set
Total character count: 36 chars
Time Prefix Settings
Precision
Fixed String Settings
e.g. "uap" = 3
e.g. 2 × "-"
Total fixed length: 17 chars
Collision Probability
Target collision probability10^-6
10⁻¹²10⁻³
10⁻⁶ = one in a million, industry safety standard
Primary Key Format Preview
Format structure
{Prefix(3)}-{Timestamp(12)}-{Random(7)}
Example
uap-019cbc0dc7e3-coseizq
Total length24
VARCHAR suggestionVARCHAR(24)
Random Length Reference Table
| Random length | Combinations (N) | Safe peak | Per second | VARCHAR | Scenario |
|---|---|---|---|---|---|
| 1 | 36 | 8.5e-3 | 8 | 18 | ❌Unusable, collision probability too high |
| 2 | 1,296 | 0.05 | 50 | 19 | ❌Unusable, collision probability too high |
| 3 | 46,656 | 0.31 | 305 | 20 | ❌Unusable, collision probability too high |
| 4 | 1.68e+6 | 1 | 1,832 | 21 | ⚠️Ultra low, test environment only |
| 5 | 6.05e+7 | 10 | 10,996 | 22 | ⚠️Low, small internal systems |
| 6 | 2.18e+9 | 65 | 65,981 | 23 | ⚠️Low, small internal systems |
| 7Recommended | 7.84e+10 | 395 | 395,889 | 24 | ✅Medium-low, small websites |
| 8 | 2.82e+12 | 2,375 | ~238 萬 | 25 | ✅Medium, general SaaS services |
| 9 | 1.02e+14 | 14,252 | ~1425 萬 | 26 | ✅Medium-high, mid-large platforms |
| 10 | 3.66e+15 | 85,512 | ~8551 萬 | 27 | ✅Medium-high, mid-large platforms |
| 11 | 1.32e+17 | 513,072 | ~5.1 億 | 28 | ✅High, large web services |
| 12 | 4.74e+18 | ~308 萬 | ~30.8 億 | 29 | ✅Very high, large distributed systems |
| 13 | 1.71e+20 | ~1847 萬 | ~184.7 億 | 30 | ✅Very high, large distributed systems |
| 14 | 6.14e+21 | ~1.1 億 | ~1108.2 億 | 31 | ✅Extreme, global-scale services |
| 15 | 2.21e+23 | ~6.6 億 | ~6649.4 億 | 32 | ✅Extreme, global-scale services |
| 16 | 7.96e+24 | ~39.9 億 | ~4.0 兆 | 33 | ✅Extreme, global-scale services |
| 17 | 2.87e+26 | ~239.4 億 | ~23.9 兆 | 34 | ✅Astronomical, theoretically zero collision |
| 18 | 1.03e+28 | ~1436.3 億 | ~143.6 兆 | 35 | ✅Astronomical, theoretically zero collision |
| 19 | 3.71e+29 | ~8617.6 億 | ~861.8 兆 | 36 | ✅Astronomical, theoretically zero collision |
| 20 | 1.34e+31 | ~5.2 兆 | ~5170.6 兆 | 37 | ✅Astronomical, theoretically zero collision |