Dev Compression

448 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
448
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Dev Compression

  1. 1. Vinod Kumar M Technology Evangelist – DB and BI Microsoft Corporation www.ExtremeExperts.com
  2. 2. Session Objectives And Takeaways Session Objectives Why data compression? Describe data compression in SQL Server Describe Space/Performance trade-offs Key Takeaways Can reduce size of a database significantly Easy to enable/disable No application changes Performance gains
  3. 3. Agenda What is the problem? Solution Compression in SQL Server 2008
  4. 4. Problem Large Database Storage Cost Workload Performance Manageability Cost Backup/Recovery
  5. 5. Solution Reduce the size of the database Reduce the information stored Compress the data Compress 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
  6. 6. Agenda What is the problem? Solution Compression in SQL Server 2008
  7. 7. Compression in SQL Server SQL Server 2008 ROW and PAGE compression Backup Compression Two key changes Efficient storage of data within row (both for data and index) Reduce Data Redundancy on the page
  8. 8. Efficient Storage in the ROW Variable Length Encoding (new row format) 4-byte integer SQL2005 0 0 0 1 4 bytes SQL2008 1 (compression enabled) Special Handling of NULL and 0s CHAR data type storage optimization
  9. 9. Reduce Data Redundancy: Column Prefix Factor 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))
  10. 10. Column Prefix Page Header Lambert 5000000 NULL 4 0x5B8D80 5 20x41 0x41AABB 20x42 0x5CAABB 20x43 0x9A4041 0x112233
  11. 11. 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
  12. 12. Page Dictionary Page Header Lambert 5000000 NULL Column prefix Page Dictionary 4 0x5B8D80 1 5 20x41 0x41AABB 20x42 0x5CAABB 0 20x43 0x9A4041 0 1 0x112233
  13. 13. Enabling Compression Enterprise Edition only Types of data compressions ROW Stores fixed length values as variable length Superset of vardecimal storage format Row metadata optimized BLOB/LOB is not ROW compressed PAGE (includes ROW) Column Prefix Dictionary Only in-row BLOB/LOB can potentially benefit from PAGE compression
  14. 14. Enabling Compression Examples Unpartitioned table Index Index Index Uncompressed Table Table PAGE Compressed
  15. 15. Enabling Compression Examples Latest partition uncompressed Uncompressed PAGE Compressed ROW Compressed Jan-Mar Apr-June July-Sept Oct-Dec
  16. 16. 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)
  17. 17. Enabling Compression… Estimate space savings sp_estimate_data_compression_savings Space savings depend upon Schema Data Distribution
  18. 18. Let us estimate ….
  19. 19. DML Operations INSERT (PAGE Compressed) PAGE Compressed ROW Compressed Header Header CI structure
  20. 20. Table And PAGE Compression Uncompressed PAGE Compressed ROW Compressed
  21. 21. Btree And PAGE Compression Uncompressed PAGE Compressed ROOT ROW Compressed INTERNAL INTERNAL INTERNAL INTERNAL LEAF LEAF LEAF LEAF
  22. 22. Impact Of Data Compression Application No changes needed in the application Application throughput increase if I/O bound Utilities All Database Utilities (e.g. Backup, Index, DBCC) fully supported Gains if I/O bound
  23. 23. Supportability DBCC PAGE enhanced New Perfmon counters Page Compression attempts/sec Page Compressed/sec New columns in DMVs sys.db_index_physical_stats compressed_pages_count sys.db_index_operational_stats Page_compression_success_count Page_compression_attempt_count
  24. 24. Summary – Compression Can reduce size of database significantly Lower total cost of ownership (TCO) Easy to enable/disable No application changes Performance gains
  25. 25. 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)
  26. 26. Track Resources Resource 1 Resource 2 Resource 3 Resource 4
  27. 27. © 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.

×