在网上搜索时,我发现在指定超宽VARCHAR列(例如VARCHAR(30)可能会这样做时,例如VARCHAR(255))时是否会对性能产生影响的建议相互冲突。
我始终认为,如果整行超过8060字节,则会对性能造成影响。除此之外,我看到了分歧。
要求是真的The default is SET ANSI PADDING ON = potential for lots of trailing spaces
吗?只要总行宽小于8060,在VARCHAR列过大设置时是否存在真正的性能问题?
列宽很重要的证据
The same goes for CHAR and VARCHAR data types. Don’t specify more characters in character columns that you need.
http://www.sql-server-performance.com/2007/datatypes/
Length is a constraint on the data (like CHECK, FK, NULL etc)
Performance when the row exceeds 8060 bytes
Can not have unique constraint or index (key column width must be < 900)
The default is SET ANSI PADDING ON = potential for lots of trailing spaces
列宽无关紧要的证据
If you're talking about varchar and nvarchar then no, there is no penalty for allowing a higher field length.
/programming/7025996/overstating-field-size-in-database-design
The varchar datatype, by contrast, consumes only the amount of
actual space used plus 2 bytes for overhead
http://sqlfool.com/content/PerformanceConsiderationsOfDataTypes.pdf
max
fromnon max
)。具有较高开销的是相反的方向。