estimateCompressionRatio
Introduced in: v25.4.0
Estimates the compression ratio of a given column without compressing it.
For the examples below, the result will differ based on the default compression codec of the server.
See Column Compression Codecs.
Syntax
estimateCompressionRatio([codec, block_size_bytes])(column)
Parameters
codec — String containing a compression codec or multiple comma-separated codecs in a single string. String
block_size_bytes — Block size of compressed data. This is similar to setting both max_compress_block_size and min_compress_block_size. The default value is 1 MiB (1048576 bytes). Maximum allowed value is 256 MiB (268435456 bytes). UInt64
Arguments
column — Column of any type. Any
Returned value
Returns an estimate compression ratio for the given column. Float64
Examples
Basic usage with default codec
CREATE TABLE compression_estimate_example
(
`number` UInt64
)
ENGINE = MergeTree()
ORDER BY number
SETTINGS min_bytes_for_wide_part = 0;
INSERT INTO compression_estimate_example
SELECT number FROM system.numbers LIMIT 100_000;
SELECT estimateCompressionRatio(number) AS estimate FROM compression_estimate_example
┌───────────estimate─┐
│ 1.9988506608699999 │
└────────────────────┘
Using a specific codec
SELECT estimateCompressionRatio('T64')(number) AS estimate FROM compression_estimate_example
┌──────────estimate─┐
│ 3.762758101688538 │
└───────────────────┘
Using multiple codecs
SELECT estimateCompressionRatio('T64, ZSTD')(number) AS estimate FROM compression_estimate_example
┌───────────estimate─┐
│ 143.60078980434392 │
└────────────────────┘
Last modified on June 8, 2026