Skip to content

mjcrockett/compression-in-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

compression-for-db

The point of this proof-of-concept was to replicate the SQL compress method for saving to the database, doing this in the back-end code to avoid additional overhead in the database, and then being able to decompress using the basic SQL Decompress method.

The following SQL Compress method has been replicated in C#:

INSERT INTO Player ([Name], [Surname], [Info])     
VALUES ('John', 'Smith', COMPRESS(N'{"sport":"Tennis","age": 28,"rank":1,"points":15258, turn":17}'))

Therefore, after data has been inserted into the database, the same data can easily be decompressed in SQL Server Management Studio using the Decompress method:

SELECT [Id]
  ,[Name]
  ,[Surname]
  ,[Info]
  ,CAST(DECOMPRESS(Info) AS NVARCHAR(MAX)) AS  AfterCastingDecompression
FROM Player
WHERE Id = 9

Note, varbinary(max) is being used as the datatype for the compressed data in the data table.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages