When you column contains more null values then you can use sparse keyword for reduce the storage space.
E.g. In your table contains 1000 rows , out of 1000 rows more than 700 rows contain null values then you can use the sparse column to reduce the database space. Using a sparse column you can also reduced the index size.
P.S : Do not use sparse column if column contains very less null values.
More details please refer : https://www.simple-talk.com/sql/t-sql-programming/null-friendly-using-sparse-columns-and-column-sets-in-sql-server/
E.g. In your table contains 1000 rows , out of 1000 rows more than 700 rows contain null values then you can use the sparse column to reduce the database space. Using a sparse column you can also reduced the index size.
CREATE TABLE Student_sparse ( STUDENTID INT IDENTITY(5001,1) PRIMARY KEY, SSN CHAR(9) NOT NULL, TITLE CHAR(10) SPARSE NULL, FIRSTNAME VARCHAR(50) NOT NULL, MIDDLEINIT CHAR(1) SPARSE NULL, LASTNAME VARCHAR(50) NOT NULL, EMAIL CHAR(50) SPARSE NULL) GO
P.S : Do not use sparse column if column contains very less null values.
More details please refer : https://www.simple-talk.com/sql/t-sql-programming/null-friendly-using-sparse-columns-and-column-sets-in-sql-server/
No comments:
Post a Comment