dev compression

Post on 05-Jul-2015

325 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Vinod Kumar MTechnology Evangelist – DB and BIMicrosoft Corporationwww.ExtremeExperts.com

Session ObjectivesWhy data compression?

Describe data compression in SQL Server

Describe Space/Performance trade-offs

Key TakeawaysCan reduce size of a database significantly

Easy to enable/disable

No application changes

Performance gains

Session Objectives And Takeaways

Agenda

What is the problem?

Solution

Compression in SQL Server 2008

Problem

Large DatabaseStorage Cost

Workload Performance

Manageability CostBackup/Recovery

Solution

Reduce the size of the databaseReduce the information stored

Compress the dataCompress the data file

No benefit in-memory

Need to compress larger chunks, does not scale for random access

Store data efficiently in the row/page

(+) More data can fit in memory

(+) Better Performance for I/O bound workload

(-) Performance degradation for CPU bound workload

Agenda

What is the problem?

Solution

Compression in SQL Server 2008

Compression in SQL Server

SQL Server 2008 ROW and PAGE compression

Backup Compression

Two key changesEfficient storage of data within row (both for data and index)

Reduce Data Redundancy on the page

Efficient Storage in the ROW

Variable Length Encoding (new row format)

0 0 0 1

4-byte integer

1SQL2008 (compression enabled)

4 bytes

Special Handling of NULL and 0s

CHAR data type storage optimization

SQL2005

Reduce Data Redundancy:Column PrefixFactor out common prefix from the same column across all rows on the page

Store these ‘prefix’ values once and then reference them from respective columns

Example:Student (Name VARCHAR (10),

ID INT,

CODE VARBINARY(3))

Column Prefix

Page Header

0x5B8D80

0x41AABB

0x9A4041

0x112233

0x5CAABB

Lambert 5000000 NULL

4

5 20x41

20x43

20x42

Reduce Data Redundancy: Page Dictionary

Find repeating values across all columns on all the rows on the page

Store these values in a dictionary once and reference them from respective columns

Page Dictionary

Page Header

0x5B8D80

0x41AABB

0x9A4041

0x112233

0x5CAABB

Lambert 5000000 NULL

4

5 20x41

20x43

20x42

Column prefix

Page Dictionary

1

1

0

0

Enabling Compression

Enterprise Edition onlyTypes of data compressions

ROW Stores fixed length values as variable lengthSuperset of vardecimal storage formatRow metadata optimizedBLOB/LOB is not ROW compressed

PAGE (includes ROW)Column PrefixDictionaryOnly in-row BLOB/LOB can potentially benefit from PAGE compression

Enabling Compression Examples

Unpartitioned table

Table

Index

PAGE Compressed

Index

Uncompressed

Table

Index

Enabling Compression ExamplesLatest partition uncompressed

Jan-Mar Apr-June July-Sept Oct-Dec

PAGE Compressed

Uncompressed

ROW Compressed

Data Compression TSQL Example

CREATE TABLE T (c1 int, c2 char(2000) )

WITH (DATA_COMPRESSION = ROW)

CREATE TABLE T_Part (c1 int, c2 char(2000) )

ON somePartScheme (c1)

WITH

(DATA_COMPRESSION = PAGE ON PARTITIONS (1-7),

DATA_COMPRESSION = NONE ON PARTITIONS (8) )

ALTER INDEX CI ON T REBUILD

WITH (DATA_COMPRESSION=PAGE)

ALTER INDEX CI ON T REBUILD PARTITION = 3

WITH (DATA_COMPRESSION=PAGE)

Enabling Compression…

Estimate space savingssp_estimate_data_compression_savings

Space savings depend uponSchema

Data Distribution

Let us estimate ….

DML Operations

INSERT (PAGE Compressed)

Header

CI structure

Header

PAGE Compressed

ROW Compressed

Table And PAGE Compression

PAGE Compressed

Uncompressed

ROW Compressed

Btree And PAGE Compression

ROOT

INTERNALINTERNAL INTERNAL

LEAFLEAFLEAFLEAF

INTERNAL

PAGE Compressed

Uncompressed

ROW Compressed

Impact Of Data Compression

ApplicationNo changes needed in the application

Application throughput increase if I/O bound

UtilitiesAll Database Utilities (e.g. Backup, Index, DBCC) fully supported

Gains if I/O bound

SupportabilityDBCC PAGE enhanced

New Perfmon countersPage Compression attempts/sec

Page Compressed/sec

New columns in DMVssys.db_index_physical_stats

compressed_pages_count

sys.db_index_operational_statsPage_compression_success_count

Page_compression_attempt_count

Summary – Compression

Can reduce size of database significantly

Lower total cost of ownership (TCO)

Easy to enable/disable

No application changes

Performance gains

Related Content

Breakout Sessions (session codes and titles)

Interactive Theater Sessions (session codes and titles)

Hands-on Labs (session codes and titles)

Hands-on Labs (session codes and titles)

Track Resources

Resource 1

Resource 2

Resource 3

Resource 4

© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,

IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

top related