When to fix auto-increment gaps in MYSQL

后端 未结 2 1681
再見小時候
再見小時候 2021-01-23 04:19

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 tho

2条回答
  •  -上瘾入骨i
    2021-01-23 04:53

    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 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.

提交回复
热议问题