Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Accelerating Database Performance with Compression

Presentation about the potential benefits and costs of using data compression within SQL Server. Presented to NJ SQL Group 19 March 2012

  • Login to see the comments

  • Be the first to like this

Accelerating Database Performance with Compression

  1. 1. Accelerating DatabasePerformance UsingCompressionJoey D’AntoniNew Jersey SQL Server Users Group19 March 2013
  2. 2.  Principal Architect SQL Server, Comcast Cable  @jdanton – TwitterAbout Me  
  3. 3. Compression—What Does It Really Mean?Overview Deduplication—What is That? What Should I Compress? Columnstore—How Is It Different?
  4. 4. Compression
  5. 5.  Specialized compression to eliminate duplicate copies of repeating data  Real Example—In VMWare, you may have 10 copies of WindowsDeduplication running on same physical machine. Memory blocks (Common .dlls for example) may be deduplicated.  Backups
  6. 6. Faster performance on selectsBenefits of Less I/O is required to return dataCompression Better Space Utilization on Disk More Pages In Memory
  7. 7. Expenses of  Added CPU CyclesCompression  Slower bulk inserts and updates
  8. 8. Row CompressionSQL Server Page CompressionCompression  Prefix CompressionTypes  Dictionary Compression  Backup Compression
  9. 9.  In all editions of SQL Server, starting with 2008 R2  Always use Backup Compression (even whenBackup your storage team says no)Compression  Space is by default pre-allocated for estimated size of uncompressed backup  Trace Flag 3042
  10. 10. SQL Data Compression gives a great deal of flexibility Can compress tables, indexes and/orSo What To partitioningCompress Can use different methods of compression How to Decide?
  11. 11.  sp_estimate_data_compression_savings What Won’t Compress Well  Columns with numeric or fixed-length character data types where most values require all the bytes allocated for the specific data typeSpace Savings  Not much repeating data  Repeating data with non-repeating prefixes  Data stored out of the row  FILESTREAM data
  12. 12.  Microsoft advises using for Row Compression for EVERYTHING ifApplication you can spare 10% CPU. Don’t do this!Workloads  Page Compression has higher overhead
  13. 13. Savings Savings Table Scans Updates Decision Notes ROW % PAGE % T1 80% 90% 3.80% 57.27% ROW Low S, very high U. ROW savings close to PAGE T2 15% 89% 92.46% 0% PAGE Very high S T3 30% 81% 27.14% 4.17% ROW Low SExample T4 38% 83% 89.16% 10.54% ROW High U T5 21% 87% 0.00% 0% PAGE Append ONLY table T6 28% 87% 87.54% 0% PAGE High S, low U T7 99% appends-source Microsoft Compression White Paper T8 29% 88% 0.50% 0% PAGE 85% appends 30% 90% 11.44% 0.06% PAGE T9 84% 92% 0.02% 0.00% ROW ROW savings ~= PAGE T10 15% 89% 100.00% 0.00% PAGE Read ONLY table
  14. 14.  Tables and Indexes are rebuilt using ALTER TABLE…REBUILD and ALTER INDEX..REBUILD  Requires workspace, CPU and I/OWhat Happens  Same mechanism as rebuilding an indexwith  Free workspace required in  User DatabaseCompression  Transaction Log  Temp B
  15. 15.  Online vs OfflineHow and  Concurrent vs SerialWhen  Order of Compressiong—start small and workCompress upData  SORT_IN_TEMPDB
  16. 16. Table organization Table compression setting ROW PAGE Heap The newly inserted row is The newly inserted row is row-compressed. page-compressed: · if new row goes to an existing page with page compression · if the new row is insertedManaging through BULK INSERT with TABLOCK · if the new row is insertedInserts and through INSERT INTO ... (TABLOCK) SELECT ... FROMUpdates Otherwise, the row is row- compressed.* Clustered index The newly inserted row is The newly inserted row is row-compressed. page-compressed if new row goes to an existing page with page compression Otherwise, it is row compressed until the page fills up. Page compression is attempted before a page split.**
  17. 17. Mapping Version store index for Table Transaction Sort pages for (with SI or rebuilding the compression log queries RCSI isolationUnderlying clustered index level)Data St ROW ROW NONE NONE ROW PAGE ROW NONE NONE ROW
  18. 18. What isColumnstore?
  19. 19.  Non Updateable  Limited Data Types  Can only be nonclustered indexColumnStore  No computed columnsLimiations  No sparse columns  No indexed views  One Per Table