Skip to main content
Skip to main content

estimateCompressionRatio

estimateCompressionRatio

Estimates the compression ratio of a given column without compressing it.

Syntax

estimateCompressionRatio(codec, block_size_bytes)(column)

Arguments

  • column - Column of any type

Parameters

Both parameters are optional.

Returned values

  • Returns an estimate compression ratio for the given column.

Type: Float64.

Examples

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 │
└────────────────────┘
Note

The result above will differ based on the default compression codec of the server. See Column Compression Codecs.

SELECT estimateCompressionRatio('T64')(number) AS estimate FROM compression_estimate_example;
┌──────────estimate─┐
│ 3.762758101688538 │
└───────────────────┘

The function can also specify multiple codecs:

SELECT estimateCompressionRatio('T64, ZSTD')(number) AS estimate FROM compression_estimate_example;
┌───────────estimate─┐
│ 143.60078980434392 │
└────────────────────┘