MySQL 表中的 INT 宽度对连接有什么影响吗?
MySQL 允许您指定 int 列的宽度,例如: 整数(9) 整数(10) 整数(11) 根据文档, “显示宽度元数据”仅在启用“zerofill”时由 MySQL 使用。
我的问题是这个宽度实际上对连接速度有什么影响吗? (不应该,但我自己也不是 100% 相信)
例如下面的伪代码:会
SELECT a.field FROM a, b WHERE a.int(10)=b.int(10) WHERE b.anotherfield=?
比以下伪代码更快/更好:
SELECT a.field FROM a, b WHERE a.int(8)=b.int(11) WHERE b.anotherfield=?
混合宽度整数是否还有其他“问题”? (外键等)。我只是想知道是否值得标准化所有整数的宽度。
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 width of all our ints or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要相信我的话,但我敢打赌这与性能无关。这只是显示宽度。参见http://dev.mysql.com/doc/ refman/5.0/en/numeric-type-overview.html 和 http://alexander.kirk.at/2007/08/24/what-does-size-in-intsize-of-mysql-mean/
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/