用作 mysql select/join 属性的随机代码的适当长度是多少 [英] What is a proper length of random code used as mysql select / join attribute

查看:52
本文介绍了用作 mysql select/join 属性的随机代码的适当长度是多少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为每个 mysql 行分配一个随机代码.仅使用字母数字小写字符和数字.

I assign each mysql row with a random code. Only alphanumeric lowercase characters and numbers are used.

这些随机代码用于 SELECT 和 JOIN 查询.

These random codes are used for SELECT and JOIN queries.

我通常使用 24 个字符的长度,这给出了大约 2.2x10^37 种可用组合.

Most often I use length of 24 characters which gives roughly 2.2x10^37 available combinations.

不需要检查重复项,同时确保不会发生冲突,同时将查询结果时间保持在最短的完美随机代码长度是多少?

What is the perfect random code length that does not require checking for duplicates while being certain no collisions will occur but also keeping query result time to minimum?

注意:在大表上,我使用 INDEX 作为长度为 24 的随机代码列.

Note: On big tables I use INDEX for the random code column of length 24.

推荐答案

RANDOM 代码的本质是您永远无法确定它不会被复制.如果您使用序列号,您可以保证不会有重复如果您这样做,您不妨使用具有足够大整数的 AUTO INCREMENT 选项.

The nature of a RANDOM code is that you can never be certain it will not be duplicated. You can guarantee there wont be a duplicate if you use a sequential number & if you are doing that you might as well use the AUTO INCREMENT option with a sufficiently large integer.

http://dilbert.com/strip/2001-10-25

这篇关于用作 mysql select/join 属性的随机代码的适当长度是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆