Snowflake, BigQuery & Databricks · Amazon Redshift

Column compression encodings in Redshift

awsMediumredshiftcompressionencodingsstorage-optimization

Interview question

How do column compression encodings work in Redshift, and how do you choose them?

How to answer

The short answer

Compression encoding specifies the algorithm used to compress data within each column's one-megabyte disk blocks. Applying proper column encodings reduces storage costs by 60% to 80% and accelerates query performance, because reading compressed blocks from disk requires less I/O bandwidth.

Common Redshift encodings

  • AZ64: A proprietary Amazon algorithm designed specifically for Redshift. It achieves high compression ratios comparable to ZSTD while delivering significantly faster decompression speeds. It is the recommended default for numeric (INTEGER, DECIMAL) and date or timestamp columns.
  • ZSTD: A modern dictionary-based algorithm that provides exceptional compression across almost all , particularly wide alphanumeric string columns and text.
  • Run Length (RLE): Replaces consecutive repeated values with a value and a count token. Excellent for low-cardinality columns where the table is sorted on that column.
  • RAW: No compression applied. This is generally reserved for columns that serve as the leading sort key, because uncompressed blocks allow zone maps to scan without decompression overhead.
SQL
CREATE TABLE order_items (
    item_id BIGINT ENCODE az64,
    order_date DATE ENCODE raw, -- Sort key column
    category VARCHAR(50) ENCODE zstd,
    status VARCHAR(20) ENCODE runlength
);

Analyzing compression

If you are unsure which encoding to pick, Redshift provides an automated utility:

SQL
ANALYZE COMPRESSION sales_history;

This command inspects a sample of existing rows and outputs the optimal encoding recommendation for every column. When loading a brand new table using the COPY command with an empty table, Redshift automatically selects and applies encodings if none are defined.