MySQL primary/foreign key size?

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-05-15T17:58:35Z Indexed on 2010/05/15 18:04 UTC
Read the original article Hit count: 291

Filed under:
|
|
|
|

I seem to see a lot of people arbitrarily assigning large sizes to primary/foreign key fields in their MySQL schemas, such as INT(11) and even BIGINT(20) as WordPress uses.

Now correct me if I'm wrong, but even an INT(4) would support (unsigned) values up to over 4 billion. Change it to INT(5) and you allow for values up to a quadrillion, which is more than you would ever need, unless possibly you're storing geodata at NASA/Google, which I'm sure most of us aren't.

Is there a reason people use such large sizes for their primary keys? Seems like a waste to me...

© Stack Overflow or respective owner

Related posts about mysql

Related posts about primary-key