overhead of varchar(max) columns with small data

前端 未结 5 1137
旧巷少年郎
旧巷少年郎 2021-01-17 10:29

As part of a bulk load of data from an external source the stageing table is defined with varchar(max) columns. The idea being that each column will be able to hold whateve

5条回答
  •  野的像风
    2021-01-17 11:03

    VARCHAR(MAX) column values will be stored IN the table row, space permitting. So if you have a single VARCHAR(MAX) field and it's 200, 300 byte, chances are it'll be stored inline with the rest of your data. No problem or additional overhead here.

    Only when the entire data of a single row cannot fit on a single SQL Server page (8K) anymore, only then will SQL Server move VARCHAR(MAX) data into overflow pages.

    So all in all, I think you get the best of both worlds - inline storage when possible, overflow storage when necessary.

    Marc

    PS: As Mitch points out, this default behaviour can be turned off - I don't see any compelling reasons to do so, however....

提交回复
热议问题