15.10 - Using Algorithmic Compression on JSON Columns - Teradata Database

Teradata Database Teradata JSON

prodname
Teradata Database
vrm_release
15.10
created_date
December 2015
category
Programming Reference
featnum
B035-1150-151K
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. Access Orange Books through Teradata @ Your Service: https://tays.teradata.com.

For more information about compression functions, see SQL Functions, Operators, Expressions, and Predicates, B035-1145.

For information about the COMPRESS and DECOMPRESS phrases, see SQL 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);