Does with INT width in a MySQL table make any difference in Joins?
MySQL allows you to specify a width for int columns such as: int(9) int(10) int(11) which, according to the documentation, is the "display width metadata" which is only used by MySQL if you have enabled "zerofill".
My question is does this width actually make any difference to speed of Joins? (it shouldn't, but I'm not 100% convinced myself)
For example would the following pseudo-code:
SELECT a.field FROM a, b WHERE a.int(10)=b.int(10) WHERE b.anotherfield=?
be faster/better than:
SELECT a.field FROM a, b WHERE a.int(8)=b.int(11) WHERE b.anotherfield=?
Are there any other "problems" of mixed width ints? (Foreign keys etc). I just want to know if it's worth normalizing the w开发者_StackOverflow社区idth of all our ints or not.
Do not take my word on it, but I bet it does nothing to do with performance. It's just the display width. see http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html and http://alexander.kirk.at/2007/08/24/what-does-size-in-intsize-of-mysql-mean/
精彩评论