Alex Rivera | Logout

What size INT should I use for my autoincrement ids MySQL

Asked 2010-08-25T03:52:14.287
31

Currently we're using INT(21)* for all autoincrement id columns in out 30+ table database.

We are a blogging site, and have tables storing members, comments, blog posts and the like.

I'm quite sure we will never reach the limit of our INT(21) id columns, and would like to know:

  • If using INT(21) when I am sure we'll never need it is a waste of space
  • If it is a waste, what the recommended size for an autoincrement id column is

*Not my design. I'm asking this because I'm considering reducing this to say, INT(10).

Edit
Report

1 Answer

5

See here for the limit of each int type: http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

Note that INT(21) == INT(100000). The number in brackets is just how many zeros are padded to it if you specify the field should be zero-padded.

An unsigned int field can hold up to 4294967295 records (see link above).

answered 2010-08-25T04:00:23.783

Your Answer