跳到主要内容
跳到主要内容

estimateCompressionRatio

estimateCompressionRatio

估计给定列的压缩比,而不进行实际压缩。

语法

estimateCompressionRatio(codec, block_size_bytes)(column)

参数

  • column - 任意类型的列

参数

两个参数都是可选的。

返回值

  • 返回给定列的估计压缩比。

类型: Float64

示例

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

上面的结果将根据服务器的默认压缩编解码器而有所不同。请参见 列压缩编解码器

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

该函数还可以指定多个编解码器:

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