Using Algorithmic Compression on JSON Columns

Teradata Vantage™ JSON Data Type

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1150-162K
You can use the following compression functions to perform algorithmic compression (ALC) on JSON type columns:
  • JSON_COMPRESS
  • JSON_DECOMPRESS
  • TD_LZ_COMPRESS
  • TD_LZ_DECOMPRESS

You can use TD_LZ_COMPRESS to compress JSON data; however, Teradata recommends that you use JSON_COMPRESS instead because the JSON_COMPRESS function is optimized for compressing JSON data.

JSON_COMPRESS and JSON_DECOMPRESS can be used to compress JSON type columns only. These functions cannot be used to compress columns of other data types.

You cannot create your own compression and decompression user-defined functions to perform algorithmic compression on JSON type columns. You must use the functions previously listed.

You can use ALC to compress columns that store JSON data using one of the binary storage formats (BSON or UBJSON).

Using ALC together with block-level compression (BLC) may degrade performance, so this practice is not recommended. For more information on compression use cases and examples, see Teradata Orange Book Block-Level Compression in Teradata, available by logging in to https://access.teradata.com.

For more information about compression functions, see Teradata Vantage™ SQL Operators and User-Defined Functions, B035-1210.

For information about the COMPRESS and DECOMPRESS phrases, see Teradata Vantage™ Data Types and Literals, B035-1143.

Example: JSON_COMPRESS and JSON_DECOMPRESS Functions

In this example, the JSON data in the "json_col" column is compressed using the JSON_COMPRESS function. The compressed data is uncompressed using the JSON_DECOMPRESS function.

CREATE TABLE temp (
  id       INTEGER, 
  json_col JSON(1000) 
           CHARACTER SET LATIN 
           COMPRESS USING JSON_COMPRESS 
           DECOMPRESS USING JSON_DECOMPRESS);