---
title: Table Compression Options
slug: HwlNjPPuoMUjj5BxaCt06
description: Learn about table compression options in Ocient, optimizing data storage and reducing costs for large-scale data warehousing.
docTags: 
createdAt: Tue Jan 30 2024 20:44:23 GMT+0000 (Coordinated Universal Time)
updatedAt: Mon Mar 30 2026 18:52:29 GMT+0000 (Coordinated Universal Time)
---

The Ocient® System provides a range of options for compressing tables to reduce storage requirements for your data. Compression can be a major component of query optimization when used effectively by reducing I/O requirements and potentially allowing more system space for indexes.&#x20;

## Ocient Compression Key Concepts&#x20;

Table columns in Ocient can support these compression options:&#x20;

- [Global Dictionary Compression (GDC)](./#global-dictionary-compression)
- [Zstandard Compression (ZSTD)](./#zstandard-compression)
- [Dynamic Compression](./#dynamic-compression)

Ocient System compression adheres to these key concepts:&#x20;

- By default, the Ocient dynamic compression scheme can determine whether to apply compression on each column if it is statistically advantageous. Sometimes, you might want to use another compression scheme like ZSTD or completely disable compression.&#x20;
- You can specify custom compression schemes on individual columns through data definition language (DDL) commands, either using a `CREATE TABLE` or `ALTER TABLE` SQL statement.
- GDC can stack onto other compression schemes.

**General Compression Matrix**

This table shows the best compression scheme for different column data types. The suggested best compression schemes consider the column data type and cardinality, but other factors can influence which data compression makes sense.&#x20;

The default compression in the table shows the compression scheme that the database applies if you do not specify an option. This default compression balances performance and compression.&#x20;

| **Data Type**                                       | **Default Compression**                             | **Best Compression**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------------------------------------------- | --------------------------------------------------- |   |
| Fixed-length                                        | `COMPRESSION DYNAMIC`                               | `COMPRESSION ZSTD`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Variable-length and low cardinality                 | `COMPRESSION NONE`                                  | `COMPRESSION GDC` and `COMPRESSION ZSTD`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Variable-length and high cardinality                | `COMPRESSION NONE`                                  | `COMPRESSION ZSTD`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Arrays                                              | `COMPRESSION NONE`                                  | `COMPRESSION ZSTD`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Arrays of variable-length types and low cardinality | `COMPRESSION NONE`                                  | `COMPRESSION GDC` and `COMPRESSION ZSTD`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Tuples                                              | Compression depends on each tuple index data type.  | The database treats each tuple index position as its own column value and can support its own compression scheme. Fixed-length values default to `COMPRESSION DYNAMIC`, while variable-length values default to `COMPRESSION NONE`. <br />For best performance, apply rules for each tuple index based on the data-type rules outlined in this table. <br />For example: <br />`my_tuple TUPLE<<INT, VARCHAR(255) COMPRESSION GDC(1) COMPRESSION ZSTD, VARCHAR(255)>>`<br />This example defines a tuple column with GDC and ZSTD compression only for the first inner `VARCHAR` value. |

For details about the advantages and disadvantages of each compression scheme, see the `compression_scheme` description in [Column Constraint](<./././SQL Reference/Data Definition Language _DDL_ Statement Reference/Tables.md>).&#x20;

For details about the compression syntax, see [CREATE TABLE](<./././SQL Reference/Data Definition Language _DDL_ Statement Reference/Tables.md>).

## Global Dictionary Compression

Column parameter: `COMPRESSION GDC`

GDC uses a dictionary encoder to map variable-length column data. Instead of storing the variable length data directly on disk, GDC substitutes each unique string with a corresponding unique integer.&#x20;

This compression scheme can significantly reduce overall storage requirements for low-cardinality columns with a few distinct values while boosting performance for various operations.

GDC supports an optional `compression_value` argument that specifies how many unique values to use.&#x20;

**Advantages**

- Reduced disk usage — Variable-length data, such as strings or container types, can experience massive storage reduction.
- Improved query performance  — By mapping each row to an integer, variable-length rows no longer require a full traversal for selective I/O operations, which improves performance in some queries.
- Faster Joins — Join comparisons have improved performance from using GDC integers instead of the variable-length data.&#x20;
- Variable-Length Cluster Keys — Variable-length columns can use a clustering key index for improved performance.
- Stackable — Columns can use GDC in tandem with other compression schemes.&#x20;

**Disadvantages**

- Increased complexity — You must know the rough cardinality of your data to size the GDC configuration properly.&#x20;
- Load complexity — GDC compression adds some overhead to loading data into the Ocient System.
- Not suitable for high-cardinality data — GDC performance decreases as the data cardinality increases.
- Cannot apply retroactively — Unlike other compression options, you must set GDC as part of the initial `CREATE TABLE` SQL statement. You cannot apply it later to the table.&#x20;

For details, see [Global Dictionary Compression](<./Table Compression Options/Global Dictionary Compression.md>).&#x20;

```sql
column_name [data_type] COMPRESSION GDC [ (compression_value) ]
```

For details about adding GDC compression to a table schema, see  [CREATE TABLE](<./././SQL Reference/Data Definition Language _DDL_ Statement Reference/Tables.md>).

## Zstandard Compression

Column parameter: `COMPRESSION ZSTD`

ZSTD uses the ZSTD library to apply a fast and lossless compression algorithm to any column type, including fixed and variable-length scalars, arrays, and tuples on a per-component basis. In addition, ZSTD works on columns where the database first compresses variable-length data by GDC and then compresses the resulting integral type on disk. &#x20;

This compression scheme can affect performance by requiring additional processing. Therefore, this compression scheme is usually good for less-frequently accessed columns or columns paired with an index.&#x20;

ZSTD supports these optional values:

- &#x20;`COMPRESSION_LEVEL` — This value signifies how much compression the data receives. The default value is `0`. The full range of values is from `-7` (low compression) to `15` (high compression). The database requires less memory when this value is lower, whereas it requires more memory and processing resources when the value is larger.&#x20;
- `DICTIONARY_SIZE` — This value is the dictionary size that you specify as a positive integer. The value signifies the size of the shared compression dictionary in bytes. The default value is `32768` (32 KB). The full range of values ranges from 4096 (4 KB) to `1048576` (1 MB). This value denotes the amount of memory consumed during segment generation. In general, larger values provide better compression but use more memory.

:::hint{type="info"}
The default values for `COMPRESSION_LEVEL` and `DICTIONARY_SIZE` are sufficient for most cases.&#x20;
:::

**Advantages**

- Reduced disk storage — Dramatically decreases disk space usage.&#x20;
- Flexible — You can apply this compression scheme after table creation using an [ALTER TABLE](<./././SQL Reference/Data Definition Language _DDL_ Statement Reference/Tables.md>) SQL statement.&#x20;

**Disadvantages**

- Performance loss — ZSTD does require some extra CPU resources, which means that it can impact query performance.&#x20;
- Memory usage — ZSTD can demand significant memory usage when many columns use it for parallel query workloads.&#x20;

```sql
column_name [data_type] COMPRESSION ZSTD 
   [COMPRESSION_LEVEL = level_value, DICTIONARY_SIZE = size_value]
```

For details about adding ZSTD compression to a table schema, see [CREATE TABLE](<./././SQL Reference/Data Definition Language _DDL_ Statement Reference/Tables.md>).

## Dynamic Compression

Column parameter: `COMPRESSION DYNAMIC`

By default, Ocient tables use dynamic compression to reduce storage space requirements automatically. This method employs a variety of compression schemes on columns based on their data type and a statistical determination of what kinds of compression would be advantageous.

- For fixed-length data, block-size units (typically 4 KB) can receive various compression schemes, including run-length encoding and delta-delta encoding.&#x20;
- For variable-length data (VARCHAR and VARBINARY), the database compresses data row-by-row, with values individually compressed using LZ4 compression. This method produces a good compression ratio for large values. However, small or medium-sized values have negligible compression rates.&#x20;

**Advantages**

- Ease of use — The Ocient System determines the compression.&#x20;
- Flexibility — You can apply this compression scheme after table creation using an [ALTER TABLE](<./././SQL Reference/Data Definition Language _DDL_ Statement Reference/Tables.md>) SQL statement.&#x20;

**Disadvantages**

- Secondary option — Dynamic compression is designed for balance, but it is generally not as effective at compression as ZSTD.&#x20;
- Performance loss — This compression scheme has a small performance impact, but is not as costly as ZSTD.&#x20;

```sql
column_name [data_type] COMPRESSION DYNAMIC
```

For details about adding dynamic compression to a table definition, see [CREATE TABLE](<./././SQL Reference/Data Definition Language _DDL_ Statement Reference/Tables.md>).

For examples of tables that use compression, see [CREATE TABLE SQL Statement Examples](<./CREATE TABLE SQL Statement Examples.md>).

## Related Links

[Global Dictionary Compression](<./Table Compression Options/Global Dictionary Compression.md>)

[Secondary Indexes](<./Secondary Indexes.md>)



