데이터형식 | 비-스파스바이트 | 스파스바이트 | NULL백분율 |
bit | 0.125 | 4.125 | 98% |
tinyint | 1 | 5 | 86% |
smallint | 2 | 6 | 76% |
int | 4 | 8 | 64% |
bigint | 8 | 12 | 52% |
real | 4 | 8 | 64% |
float | 8 | 12 | 52% |
smallmoney | 4 | 8 | 64% |
money | 8 | 12 | 52% |
smalldatetime | 4 | 8 | 64% |
datetime | 8 | 12 | 52% |
uniqueidentifier | 16 | 20 | 43% |
date | 3 | 7 | 69% |
데이터 형식 | 비-스파스 바이트 | 스파스 바이트 | NULL 백분율 |
datetime2(0) | 6 | 10 | 57% |
datetime2(7) | 8 | 12 | 52% |
time(0) | 3 | 7 | 69% |
time(7) | 5 | 9 | 60% |
datetimetoffset(0) | 8 | 12 | 52% |
datetimetoffset (7) | 10 | 14 | 49% |
decimal/numeric(1,s) | 5 | 9 | 60% |
decimal/numeric(38,s) | 17 | 21 | 42% |
vardecimal(p,s) | decimal 형식을 일반적인 예상치로 사용 |
데이터형식 | 비-스파스바이트 | 스파스바이트 | NULL백분율 |
sql_variant | 기본데이터형식에따라다름 | ||
varchar또는char | 4+평균데이터 | 2+평균데이터 | 60% |
nvarchar또는nchar | 4+평균데이터 | 2+평균데이터 | 60% |
varbinary또는binary | 4+평균데이터 | 2+평균데이터 | 60% |
xml | 4+평균데이터 | 2+평균데이터 | 60% |
hierarchyId | 4+평균데이터 | 2+평균데이터 | 60% |
--drop table sparse_table create table sparse_table ( sparse_col nchar(4) sparse null ); --drop table non_sparse_table create table non_sparse_table ( non_sparse_col nchar(4) null ); with temp(num) as ( select 1 num union all select num + 1 from temp where num + 1 <= 10 ) insert sparse_table(sparse_col) select N'뭡니까?' -- 100000건 from temp a, temp b, temp c, temp d, temp e union all select NULL -- 100000건 from temp a, temp b, temp c, temp d, temp e; with temp(num) as ( select 1 num union all select num + 1 from temp where num + 1 <= 10 ) insert non_sparse_table(non_sparse_col) select N'뭡니까?' -- 100000건 from temp a, temp b, temp c, temp d, temp e union all select NULL -- 100000건 from temp a, temp b, temp c, temp d, temp e; exec sp_spaceused 'sparse_table' exec sp_spaceused 'non_sparse_table' /* name rows reserved data index_size unused ------------ ------ -------- ------- ---------- ------ sparse_table 200000 3720 KB 3664 KB 8 KB 48KB name rows reserved data index_size unused ------------ ------ -------- ------- ---------- ------ sparse_table 200000 3400 KB 3368 KB 8 KB 48KB */
--drop table column_sets create table column_sets ( sparse1 int primary key , sparse2 int sparse null , sparse3 nvarchar(20) sparse null , cs xml column_set FOR ALL_SPARSE_COLUMNS ); insert column_sets(sparse1, sparse2, sparse3) values (1, 1, N'이건또뭐냐?') , (2, null, N'뭐가맘에안드는데?'); select * from column_sets; select sparse1, sparse2, sparse3, cs from column_sets
CREATE TABLE t ( i int SPARSE , cs xml column_set FOR ALL_SPARSE_COLUMNS ); INSERT t(cs) VALUES ('<i/>'); SELECT i FROM t; SELECT * FROM t;