Advanced Index, Partitioning and Compression Strategies for SQL Server
Click here to load reader
-
Upload
confio-software -
Category
Technology
-
view
311 -
download
10
description
Transcript of Advanced Index, Partitioning and Compression Strategies for SQL Server
04/13/2023 1
Advanced Index, Partitioning and Compression Strategies for
SQL Server
Neil HamblySenior DBA & Engineer,
Confio Software
Who Am I?
• Senior DBA/Engineer for Confio Software– [email protected] {Based in the UK}
• DBA – 14+ Years, SQL Server 6.5 - 2012• Held # of DB roles @ many leading organizations • Regular International PASS Presenter @ SQL Conferences, User-Groups & Webinars• SQL London PASS Chapter Leader, UK Events Organizer• Regular @ UK & International community events • Twitter: @Neil_Hambly & @Confio Contributing Author
• Articles @ Confio.com & My blog
04/13/2023 2
04/13/2023 3
Agenda
• Talk about the two features – Compression & Partitioning• Using Data Compression in SQL Server 2005+
– Compression• Editions, Data types• Vardecimal Compression (2005 SP2) • Page | Row Compression (2008+)• Unicode Compression• Estimate space & resources
– Partitioning– Combining with other features– Demos
• Partition-Info Script• Finding objects for compression
• Q&A + further links
04/13/2023 4
Data Types
Data Compression was introduced in SQL 2005 (SP2) via vardecimal storageThis was superseded in SQL Server in 2008 Version (Row & Page level)
Compression feature is only available in Enterprise and Developer SKU’sNote: NULL and 0 values across all data types are optimized to take 0 bytes in addition to 4 bits/per Column
Data Type / Benefits with Data Compression Yes – depends on data No or little benefit (Normally)bit / smallint / int / bigint tinyint / uniqueidentifierdecimal / numeric datetime / datetime2 / datetimeoffset smalldatetime / date / timechar / nchar / nvarchar varchar / text / ntext / imagebinary / timestamp / Rowversion varbinarymoney / smallmoney float / real sql_variant / FileStream
cursor / table / xml
04/13/2023 5
SQL Server 2005 SP2 (Vardecimal)
The vardecimal works the same way as the varchar works for efficiently storing alphanumeric data.
HOW TO TURN ON THE VARDECIMAL OPTION
Step 1: exec sp_db_vardecimal_storage_format '<dbname>', 'ON'This option will enable the vardecimal storage on the specified database.
Step 2: exec sp_tableoption '<table>', 'vardecimal storage format', 1 This option will turn on the vardecimal storage for the existing table.
HOW TO ESTIMATE WHETHER IT IS WORTH TURNINGON THIS OPTIONsys.sp_estimated_rowsize_reduction_for_vardecimal '<table>'
Column precision
Original fixed decimal size (bytes)
Maximum vardecimal data area (bytes)
Overhead to store offset (bytes)
Maximum vardecimal storage used (bytes)
1-3 5 3 2 54-6 5 4 2 67-9 5 5 2 710-12 9 6 2 813-15 9 8 2 1016-18 9 9 2 1119 9 10 2 1220-21 13 10 2 1222-24 13 11 2 1325-27 13 13 2 1528 13 14 2 1629-30 17 14 2 1631-33 17 15 2 1734-36 17 16 2 1837-38 17 18 2 20
04/13/2023 6
Page & Row Level Compression
Since 2008 version, we have new compression algorithms available
Compressing the leaf level of tables and indexes with page compression consists of three operations, these are done in the following order:
1. Row compression2. Prefix compression3. Dictionary compression
Note: When using page compression, the non–leaf-level pages of indexes are only row compressed
Row Compression Prefix Compression Dictionary Compression
04/13/2023 7
Unicode Compression
Space savings that can be achieved for different locales (15-50%)
Standard Compression Scheme for Unicode (SCSU) SCSU algorithm to compress Unicode values that are stored in row or page compressed objects
Unicode compression supports the fixed-length nchar(n) and nvarchar(n) data types.
Data values that are stored off row or in nvarchar(max) columns are not compressed
Locale Compression %
English 50%German 50%Hindi 50%Turkish 48%Vietnamese 39%Japanese 15%
SCSU can also switch to UTF-16 internally to handle non-alphabetic languages
Supercharge SQL Server Performance with Indexing, Partitioning and Compression
View this full 60-minute webinar, compliments of Confio Software, to supercharge SQL Server performance using advanced techniques for indexing, partitioning and/or compression. You’ll learn:• How to identify which objects will benefit the most from
indexing• How to decide when you should combine indexing, partitioning
and compression • How these techniques have been applied in real-world scenarios• How to you can use available demo scripts to determine which
objects in your environment will benefit from these techniques
www.confio.com
04/13/2023 8