7

We have a mysql table that is running out of ids soon (the primary id is a 32-bit integer and the max id is already about 1.5 billion). What is the best way to fix this issue? Alter the id type to 64-bit is an option but that would bring down the database for too long because the table has billion of rows.

Pinch
  • 2,768
  • 3
  • 28
  • 44
  • What is the actual datatype of that column used in your schema – RiggsFolly Jan 23 '16 at 01:39
  • Let's talk about what you are doing to run out of ids. Do you have 1.5 billion rows? Or are most of the ids deleted? Burned? Otherwise lost? It _may_ be possible to slow down the consumption so that you won't run out. – Rick James Jan 23 '16 at 23:07

2 Answers2

3

All versions of MYSQL (both 32bit and 64bit) use an 8 byte field for a column defined as BIGINT.

So amend the column to be BIGINT

Check the documentation

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
3

then try changing the type of the field. Try some type with a big range like "BIGINT".

Iresha Rubasinghe
  • 913
  • 1
  • 10
  • 27