Nifty trick to compress LOB data

Slides:



Advertisements
Similar presentations
SQL Server Storage Engine.  Software architect at Red Gate Software  Responsible for SQL tools: ◦ SQL Compare, SQL Data Compare, SQL Packager ◦ SQL.
Advertisements

SQL Table Basics. Database Objects Tables Temporary tables (begin with #) Views Keys Indexes.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 10: Data Definition Language.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Denny Cherry twitter.com/mrdenny.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
1 Insert, Update and Delete Queries. 2 Return to you Address Book database. Insert a record.
Sofia, Bulgaria | 9-10 October TSQL Enhancements in SQL Server 2005 Stephen Forte CTO, Corzen Inc Microsoft Regional Director NY/NJ (USA) Stephen Forte.
Module 4: Data Objects. Overview Tables are the main objects that store data Indexes, views, stored programs and other objects are the support structures.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Architecture Rajesh. Components of Database Engine.
WHAT’S NEW IN SQL SERVER 2008: T-SQL Martin Bell SQL Server MVP.
Module 3 Designing a Physical Database Model. Module Overview Selecting Data Types Designing Database Tables Designing Data Integrity.
SQL Server Indexes Indexes. Overview Indexes are used to help speed search results in a database. A careful use of indexes can greatly improve search.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
Denny Cherry twitter.com/mrdenny.
Effective Indexes For Beginners. Performance is slow Let’s add another index!
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Application Data and Database Activities Auditing Dr. Gabriel.
Denny Cherry twitter.com/mrdenny.
Data Types Lesson 4. Skills Matrix Table A table stores your data. Tables are relational in that they are organized as rows and columns (a matrix). Each.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
SQL Server 2005 Implementation and Maintenance Chapter 3: Tables and Views.
Best Practices in SQL Programming. Do not use irrelevant datatype  VARCHAR instead of DATETIME  CHAR(N) instead of VARCHAR(N)  etc.
SQL SERVER DAYS 2011 Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
SQL Server 2005: Extending the Type System with XML.
شعار الشركة Ms SQL Server 2008 Express Edition. SQL Server Management Studio 2008 When we open the SQL server management studio this window are seen:
SQL SERVER DAYS 2011 Indexing Internals Denny Cherry twitter.com/mrdenny.
The Baker’s Dozen Business Intelligence 13 Productivity Tips for In-Memory OLTP Enhancements in SQL 2016 Kevin S. Goff Microsoft SQL.
October 15-18, 2013 Charlotte, NC Accelerating Database Performance Using Compression Joseph D’Antoni, Solutions Architect Anexinet.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
What is your Character Data Type? March 5, 2016 John Deardurff Website:
Doing fast! Optimizing Query performance with ColumnStore Indexes in SQL Server 2012 Margarita Naumova | SQL Master Academy.
Introduction to columnstore indexes Taras Bobrovytskyi SQL wincor nixdorf.
3 A Guide to MySQL.
Pass4itsure Microsoft Dumps
Data Definition and Data Types
The Basics of Data Manipulation
Module 2: Creating Data Types and Tables
SQL – CRUD.
Data Definition and Data Types
Ouch! Our Data Type Choices Did THAT?
Migrating a Disk-based Table to a Memory-optimized one in SQL Server
Proper DataType Usage = Guaranteed Better Performance and Accuracy
PREMIER SPONSOR GOLD SPONSORS SILVER SPONSORS BRONZE SPONSORS SUPPORTERS.
SQL Server TVP Performance Gotcha
Simple Partitioning Building a simple partitioning solution with SQL Server Stephen Fulcher.
Table Indexing for the .NET Developer
ColumnStore Index Primer
What is your Character Data Type?
Working with Data Types
Introduction to partitioning
Putting It All Together
The Basics of Data Manipulation
The Five Ws of Columnstore Indexes
Realtime Analytics OLAP & OLTP in the mix
CS122 Using Relational Databases and SQL
Denny Cherry twitter.com/mrdenny
Managing Tables.
Clustered Columnstore Indexes (SQL Server 2014)
CS1222 Using Relational Databases and SQL
Data Definition Language
Large Object Datatypes
CS122 Using Relational Databases and SQL
SQL (Structured Query Language)
SQL AUTO INCREMENT Field
When to use indexing pro Features
Presentation transcript:

Nifty trick to compress LOB data Phil Grayson Aireforge.com

Phil Grayson @databoffin Consultant at xTEN Chief ticket creator at Aireforge Organizer of Data n’ Gravy & Leeds Data Platform UG Friend of Redgate, SQLBits Blogs: philgrayson.me, blog.aireforge.com, blog.xten.uk 19 years of SQL Server experience (7.0 to 2019)

Data compression options Row Compression Page Compression Columnstore Columnstore Archival

COMPRESS() & UNCOMPRESS() To Compress COMPRESS('String here'); Returns varbinary(max) To Decompress CAST(DECOMPRESS('String here') AS VARCHAR(512)) AS Text; Note: For SQL Server 2016 use a GZIP CLR function Supported Datatypes binary(n) char(n) nchar(n) nvarchar(max) nvarchar(n) varbinary(max) varbinary(n) varchar(max) varchar(n)

SELECT TOP(10) * FROM dbo.Requests

Check the sizes Max row length Max row length (after compression) SELECT MAX(LEN(Payload)) FROM dbo.Requests; --8,000 Max row length (after compression) SELECT MAX(LEN(COMPRESS(Payload))) FROM dbo.Requests; --1,375 (82.8%) NOTE: This allows for VARBINARY(2000)

SELECT TOP(10) * FROM dbo.Requests

Computed columns

Computed columns CREATE TABLE [dbo].[Requests_Compress] ( [RequestID] [INT] IDENTITY(1, 1) PRIMARY KEY CLUSTERED NOT NULL, [Payload] AS (CONVERT([VARCHAR](MAX), DECOMPRESS([Payload_Compressed]), (0))), [Payload_Compressed] [VARBINARY](2000) NOT NULL ); INSERT INTO [dbo].[Requests_Compress] (Payload_Compressed) SELECT CONVERT(VARBINARY(2000), COMPRESS(Payload)) AS Payload_Compressed FROM dbo.Requests;

Comparing compression 4015GB Uncompressed Data 721MB Compress -82% Reduction 680MB Compress + Page -83% Reduction -5.7% Extra 668MB Compress + Row -7.3% Extra

Things to remember Requires a code change Compressed data & computed columns can’t be indexed INSERT, UPDATE & DELETE overhead Durable computed columns will consume more space

And that’s it. Any questions? Download Aireforge Studio from aireforge.com