何时修复MYSQL中的自动增量差距 [英] When to fix auto-increment gaps in MYSQL

查看:68
本文介绍了何时修复MYSQL中的自动增量差距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在使用的数据库中有成千上万的记录正在添加和删除,因此,自动递增的密钥中有数十万个空白,而自动递增的数字则有数十亿个缺口.

The database I am working on right now has records being added and removed by the 10s of thousands and because of this there are gaps in the auto-incremented key hundreds of thousands big and auto-increment numbers well into the billions.

这些数字从不存储以引用单个记录,而是在进行即时计算时用于引用记录.

These numbers are never stored to reference the individual record but are used to reference the record when doing on-the-fly calculations.

是否有任何理由消除这些差距并重设自动增量编号,或者这是无关紧要的吗?

Is there any reason to remove these gaps and reset the auto-increment number or is this inconsequential?

id字段是一个无符号的int,我应该将它增加到一个无符号的大int吗?据我了解,如果现在达到4,294,967,295,它将会崩溃.

The id field is an unsigned int, should I increase it to an unsigned big int? From what I understand, right now if it hits 4,294,967,295 it will break.

推荐答案

我担心的唯一原因是,如果您发现自己接近2 ^ 32的限制.如果您没有将列用作行ID,那么甚至不用担心.

The only reason I'd worry about it is if you find yourself close to that 2^32 limit. If you're not using the column as a row id, then don't even worry about it.

EDIT 如果您将此列用于任何类型的标识信息,那么我会将该列切换为GUID或其他内容,因为这会导致溢出,然后您会得到重复的值.那不是布宜诺斯艾利斯.

EDIT If you are using this column for any kind of identifying information, then I'd switch the column over to a GUID or something, because you're gonna get overflow, and then you'll get duplicate values. And that's no bueno.

这篇关于何时修复MYSQL中的自动增量差距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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