Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

SQL Server - Why Sparse columns will take more space to store Not null values compared to Non-Sparse columns?

Jul 15 2011 7:13AM by Ramireddy   

We all know sparse columns will save space for columns which have more null values and take more space to store not null values. Recently my colleague asked me reason behind this behavior. This is because of row format it's used to store sparse and non-sparse columns.

In case of sparse columns it stores the information in below format. Suppose, we declared 10 columns as sparse, and 5 columns in the row has not null values, then only those 5 columns details will be stored in below format.

Column Id Set : Sparse Columns which have not null values.
Column offset : relative position, where data starts 
Column values : Data of the columns,

In case of Non-sparse columns it stores the information like this. Suppose, we declared 10 columns as non-sparse, and 5 columns in a row has not null values, still all 10 columns offsets will be stored. So, it means though the column has null value, still its taking 2 bytes of space to store column offset information.

Column offset : relative position, where data starts for the sparse columns
Column values : Values of the sparse columns, which have not null values.

So, if you observe these both formats, it's clear that sparse columns will save space for columns which have null values and they will take more space for not null values (for storing Column Id Set)

Note: I didn't include fixed length columns format, while discussing non-sparse columns. They will not have any offset information. In case of non-sparse columns, it will take same storage space, whether they have NULL or NOT NULL values.

Read More..   [0 clicks]

Published under: SQL Server Tips ·  ·  ·  · 


Ramireddy
2 · 41% · 12972
4
 
2
 
 
0
Incorrect
 
0
Interesting
 
0
Forgotten



Submit

Your Comment


Sign Up or Login to post a comment.

"SQL Server - Why Sparse columns will take more space to store Not null values compared to Non-Sparse columns?" rated 5 out of 5 by 4 readers
SQL Server - Why Sparse columns will take more space to store Not null values compared to Non-Sparse columns? , 5.0 out of 5 based on 4 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]