0

I have a table column named user_id. where it auto increments whenever a new user registers.

I think setting length/values of column at its maximum length (4294967295) can prevent explosive users registering that will use up the length/values.

I'm worried if I did this, the unused length in the column could cost bits/storage in database which will slow down the processing time. Will this be the case?

Rahul Kadukar
  • 858
  • 3
  • 15
  • 35

1 Answers1

1

99.999% of the time a simple INT will do the job for thing like user_id. There's no need to get crazy. That allows for 2.1 billion users, or in other words, two people signing up per second, every second of the day, for 34 years.

Twitter, Facebook, Google and a handful of others will need a 64-bit integer for things like this. The rest of us are fine.

Don't forget that the storage cost of an INT is 4 bytes regardless of precision set. For a 64-bit number it's 8 bytes. The difference here isn't a huge deal, but in terms of index performance, INT will outperform BIGINT by a small but meaningful amount, so going BIGINT across the board is overkill in all but the most extreme cases.

Short answer: Don't worry about it. Use INT.

tadman
  • 208,517
  • 23
  • 234
  • 262