뇌를 자극하는 SQL Server 2008





SQL2008 관련하여 압축 기능을 강화하였다...

장점>>
디스크 공간이 절약된다. 
백업,복구, 인덱스 재구성등의 시간과 비용이 절감된다.
작아진 데이터를 메모리에 올림으로써 메모리의 공간이 절약되어, 다른 프로세스가 사용할 수 있는 메모리 공간이 확보

압축기능
1) 로우 압축
2) 페이지 압축
3) 백업 압축

가능 버젼
SQL2008 Ent, Dev

압축이 효과가 없는 형식
tinyint, smalldatetime, date, time, varchar, nvarchar, text, varbinary, image, cursor, sql_vairnat, uniqueidentifier, table, xmal, 사용자 정의 형식, FILESTREAM

머,, 대략,, nchar, char  고정으로 되어 있는 부분 압축하겠다는 것인데....

테스트 해보자!!!


use tableDB

go

 

------------------------

-- TABLE 생성

------------------------

create table dbo.noCompress

(

             txt char(100)

);

go

 

create table dbo.Compress

(

             txt char(100)

) with ( data_compression=row) ;

go

 

SET NOCOUNT ON;

 

------------------------

-- SampleData Insert

------------------------

DECLARE @i INT = 0;

WHILE @i < 40000

BEGIN

             INSERTINTO dbo.noCompressvalues('ABC');

             INSERTINTO dbo.Compressvalues('ABC');           

 

             SET@i+=1;

END

 

------------------------

-- 공간절약얼마나??

------------------------

exec sp_spaceused 'noCompress'

go

exec sp_spaceused 'Compress'

go

 

--name rows      reserved             data       index_size          unused

--noCompress   40000              4552 KB 4512 KB 8KB      32 KB

--Compress       40000              520 KB   464 KB   8KB      48 KB

 

 

------------------------

-- I/O를얼마나줄이느냐??

------------------------

set statistics io on

go

 

select top 100  *

from noCompress

 

 

select top 100  *

from Compress

go

 

-- 우와,, 많이절약되는구낭

--테이블'noCompress'. 검색수1, 논리적읽기수2, 물리적읽기수0,미리읽기수0, LOB 논리적읽기수0, LOB 물리적읽기수0, LOB 미리읽기수0.

--테이블'Compress'. 검색수1, 논리적읽기수1, 물리적읽기수0,미리읽기수0, LOB 논리적읽기수0, LOB 물리적읽기수0, LOB 미리읽기수0.

--go

 

------------------------

-- 압축을하였을경우얼마나절약할수있는지예측프로시져

------------------------

exec sp_estimate_data_compression_savings'dbo', 'noCompress', null, null, 'row';

go

 

--object_name   schema_name   index_id              partition_number size_with_current_compression_setting(KB)             size_with_requested_compression_setting(KB)      sample_size_with_current_compression_setting(KB)             sample_size_with_requested_compression_setting(KB)

--noCompress   dbo       0            1            4520      472        4344      456

 

--------------------------

--nocompress table 행압축시도

--------------------------

ALTER TABLE dbo.noCompress

             REBUILDWITH(DATA_COMPRESSION=ROW);

GO

 

exec sp_spaceused 'noCompress'

go

            

            

 




위의 내용을 내 프로젝트에 적용해보려고 하지만,,, 압축률이 얼마나 나올지,,궁굼하다,, 대 부분이 가변형이라,,, 허흠,,,,
압축이 된다면,, 어떤게? 단점일까?? UPDATE 비용이 커질려나??? 허흠,,


-- 2010.01.13
int형에 압축율이 얼마 되는지 확인해 보았다. 당근이^^ 고정형 문자열에 비해 높은 압축이 되지 않았지만,,, 대용량 시스템에서 가능할 법도 한???


--noCompress_int           40000               1160KB 1128 KB 8KB      24 KB

--Compress_int  40000              904 KB   880 KB   8KB      16 KB