Skip to main content
VeloDB Cloud 26.x is based on Apache Doris 4.x. See Version Mapping.

Data Compression

VeloDB Cloud organizes and stores data using a columnar storage model, which is especially well-suited for analytical workloads. Because data within the same column typically shares similar distribution characteristics, columnar storage offers a natural advantage for compression. The engine includes several compression algorithms, and you can choose the most appropriate one when creating a table to balance storage cost against query performance based on your workload.

Quick selection guide​

Different workloads have different compression requirements. The following table lists starting points to evaluate with representative data:

User scenarioAlgorithms to evaluateTrade-off to measure
Real-time analytics and high-concurrency queriesLZ4, SnappyIngestion and decompression CPU versus stored size
Balance storage size and query performanceZSTD, LZ4FCompression ratio versus ingestion and query cost
Prioritize stored size over query latencyZSTD, ZlibSize reduction versus compression and decompression work
Rarely queried dataZlib, LZ4HCStored size and the cost of loading and reading the data

Tip:

ZSTD is a useful starting point for evaluation. Compare it with other algorithms on your workload; the table does not establish a universal ranking or guarantee query speedups.

Why compression is needed​

Data compression serves two main goals:

  1. Reduce storage cost: Lowering the space required to store data in object storage and the local cache.
  2. Improve query performance: Compressed pages can reduce bytes read from storage, but decompression also consumes CPU. The net effect on query latency depends on the workload.

Supported compression algorithms​

The table compression property supports the following algorithms. Each algorithm offers a different trade-off between compression ratio and decompression speed:

Compression typeCharacteristicsApplicable scenarios
No compression (no_compression)Stores pages without codec compressionA baseline for comparison, or data that does not benefit from compression
LZ4 (lz4)Designed for fast compression and decompressionWorkloads where codec CPU cost matters
LZ4F (lz4f)Uses the LZ4 frame formatAn alternative to compare with LZ4; the table property does not expose frame tuning
LZ4HC (lz4hc)Uses more compression work to seek a smaller result than LZ4Workloads where size savings may justify ingestion cost
ZSTD (zstd)Balances stored size and codec costA starting point for mixed storage and query requirements
Snappy (snappy)Designed for fast compression and decompressionWorkloads where codec CPU cost matters
Zlib (zlib)Uses DEFLATE compressionWorkloads where stored size may justify additional codec cost

The table property selects a codec, not a per-column algorithm or compression level. Measure stored size, ingestion throughput, CPU, and query latency before choosing.

How compression works​

Compression is implemented across several layers:

Per-column compression​

Because the engine uses columnar storage, it compresses column data independently. Values within a column often share characteristics that help compression. The compression table property selects the codec used for those column pages; it does not select a different codec for each column.

Encoding before compression​

Before performing compression, the engine first encodes the column data, transforming it into a form that is better suited for compression and further improving the compression ratio. Common encoding methods include:

  • Dictionary encoding: Replaces repeated strings with shorter dictionary IDs.
  • Run-length encoding (RLE): Represents consecutive repeated values as "value + repeat count".

Per-page compression​

The engine uses a page-level compression strategy:

  1. The data of each column is divided into multiple pages.
  2. Data within each page is compressed independently.
  3. At query time, only the target pages are decompressed on demand, avoiding full-column scans.

Per-page compression can efficiently handle large-scale datasets while maintaining a good balance between compression ratio and decompression performance.

Storage format V3 optimization​

Storage format V3 changes the default encoding for signed integer types:

  • Signed integer types such as INT and BIGINT use PLAIN_ENCODING by default. Floating-point, date, and decimal types retain their type-specific encodings.
  • Encoding and compression affect different stages of execution. Evaluate their combined effect on your workload.

For details, see Storage Format V3.

Configurable compression strategy​

You can specify the compression algorithm when creating a table, choosing the best trade-off between compression efficiency and query performance based on your specific workload.

Factors that affect compression​

Compression effectiveness depends not only on the chosen algorithm but also on the characteristics of the data itself:

FactorDescription
Data orderOrdering changes the local patterns within pages and can affect encoding and compression.
Data redundancyRepeated values can help encoding and compression; dictionary encoding is useful for repeated strings.
Data type and value distributionRepresentation, range, and repetition affect the encoded pages. No data type is always easier to compress.
Value lengthLength and repetition of values affect results; shorter values do not universally produce better compression.
NULL value ratioNullability information and value distribution affect the stored representation.

Configure compression in VeloDB Cloud​

When creating a table, specify the compression algorithm via the compression parameter in PROPERTIES:

CREATE TABLE example_table (
id INT,
name STRING,
age INT
)
DUPLICATE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 10
PROPERTIES (
"compression" = "zstd"
);

Supported values for compression are no_compression, lz4, lz4f, lz4hc, zstd, snappy, and zlib. Set the property explicitly when a particular algorithm is required. If it is omitted, the engine uses its configured default; inspect the resulting table with SHOW CREATE TABLE example_table rather than assuming the effective warehouse setting.