首页 > 代码库 > Data Compression(1)
Data Compression(1)
Supported
ü SQL SERVER 2008,2012 Enterprise, Developer Edition
Notice :Backup compression is different of Data Compression. Backup compression was introduced in SQL Server 2008 Enterprise. Beginning in SQL Server 2008 R2, backup compression is supported by SQL Server 2008 R2 Standard and all higher editions. At installation, the default behavior is no backup compression. But this default can be changed by setting the backup compression default server configuration option.(USE master; GO EXEC sp_configure ‘backup compression default’, ‘1‘; RECONFIGURE WITH OVERRIDE;)
Advantage
ü Better use of the IO( because one page can contain more data ,the same amount of data required less page )
ü Better use of the Memory(because buffer can cache more data)
ü Reduce page latch(because one page can contain more data)
Disadvantage
ü Cost more CPU(compression and decompression data will need cpu to work )
can be applied to following objects
ü A whole table that is stored as a heap
ü A whole table that is stored as a clustered index
ü A whole nonclustered index
ü A whole indexed view
ü Partition table and index,any partitions can use different compression setting
Compression type
ü Row Compression
ü Page Compression
Application
ü On table
ü On index
ü On Partition Table/View
When partition has some change, the compression setting will be applied as follows
- Dividing partition : Both partition will inherit the original partition Settings
- Merging partition : Merge partitions inheritance destination partition Settings
- Switching partition: The compression settings of original partition and destination partition must be matched.
- Drop partition clustered index : Table keep compression Settings
- Estimate space saved
ü Sp_estimate_data_compression_savings
ü Data compression wizard
Monitor data compression
ü Instance level
- Performance Monitor->SQL Server:Access Method
- Page compression attempts/sec
- Page compressed/sec
ü Database object Level
- Sys.dm_db_index_operational_stats
- Sys.dm_db_index_physical_stats
considerations
- Compression is not available for system tables.
- Compression is not available for sparse columns.
- Because of their size, large-value data types are sometimes stored separately from the normal row data on special pages. Data compression is not available for the data that is stored separately.
- Changing the compression setting of a heap requires all nonclustered indexes on the table to be rebuilt so that they have pointers to the new row locations in the heap.
- When you are compressing indexes, leaf-level page can be compressed with both row and page compression .Non-leaf-level pages do not receive page compression.
- When delete the clustered index, the table’s data compression setting will be unchanged. When a clustered index is create on a heap, the clustered index inherits the compression state of the heap unless an alternative compression state is specified.
- Nonclustered indexes don’t inherit the table compression setting.
- You can enable or disable row or page compression online or offline. Enabling compression on a heap is single threaded for an online operation.
- New pages allocated in a heap as part of DML operations will not use page compression until the heap is rebuilt.
- The disk space requirements for enabling or disabling row or page compression are the same as for creating or rebuilding an index. For partitioned data, you can reduce the space that is required by enabling or disabling compression for one partition at a time.