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

后端 未结 5 1880
醉酒成梦
醉酒成梦 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:33

    From SQL SERVER – 2008 – Introduction to SPARSE Columns – Part 2 by Pinal Dave:

    All SPARSE columns are stored as one XML column in database. Let us see some of the advantage and disadvantage of SPARSE column.

    Advantages of SPARSE column are:

    • INSERT, UPDATE, and DELETE statements can reference the sparse columns by name. SPARSE column can work as one XML column as well.

    • SPARSE column can take advantage of filtered Indexes, where data are filled in the row.

    • SPARSE column saves lots of database space when there are zero or null values in database.

    Disadvantages of SPARSE column are:

    • SPARSE column does not have IDENTITY or ROWGUIDCOL property.

    • SPARSE column can not be applied on text, ntext, image, timestamp, geometry, geography or user defined datatypes.

    • SPARSE column can not have default value or rule or computed column.

    • Clustered index or a unique primary key index can not be applied SPARSE column. SPARSE column can not be part of clustered index key.

    • Table containing SPARSE column can have maximum size of 8018 bytes instead of regular 8060 bytes. A table operation which involves SPARSE column takes performance hit over regular column.

提交回复
热议问题