Variable length Columns vs Fixed length


Variable length Columns vs Fixed length

Are there any performance implication using Variable / Fixed lenght Columns.

i've passed a URl where it recommend alwasy using Fixed lenght for performacne reason.

However,  i would have expected variable lenght possible minimze physical row size  (based on the column data) which minimizes IO and possibly improve performance.

Junior Contributor

Re: Variable length Columns vs Fixed length

There's four bytes overhead for the first variabe column and two bytes for each additional VarChar. So VarChars are used when the average length of the string is at least two bytes less than the maximum 

Fixed length should be used for short strings up to a few chars or strings which always have a fixed length.

VarChars will only impact performance when they're sized too large (e.g. VARCHAR(255) for everything without checking the actiual data) because they will be expanded to CHARs in spool for ORDER/GROUP/PARTITION BY.