Why & When should I use SPARSE COLUMN? (SQL SERVER 2008)

后端 未结 5 1883
醉酒成梦
醉酒成梦 2020-11-30 02:39

After going thru some tutorials on SQL Server 2008\'s new feature \"SPARSE COLUMN\", I have found that it doesn\'t take any space if the column value is 0 or NULL but when t

5条回答
  •  难免孤独
    2020-11-30 03:37

    You're reading it wrong - it never takes 4x the space.

    Specifically, it says 4* (4 bytes, see footnote), not 4x (multiply by 4). The only case where it's exactly 4x the space is a char(4), which would see savings if the NULLs exist more than 64% of the time.

    "*The length is equal to the average of the data that is contained in the type, plus 2 or 4 bytes."

提交回复
热议问题