跳转到主内容
跳转到主内容

estimateCompressionRatio

estimateCompressionRatio

引入于:v25.4

在不压缩给定列的情况下估算其压缩比。

注意

对于下面的示例,结果会因服务器的默认压缩编解码器而有所不同。 参见 列压缩编解码器

语法

estimateCompressionRatio([codec, block_size_bytes])(column)

参数

参数说明

  • column — 任意类型的列。Any

返回值

返回指定列的压缩比估算值。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 │
└────────────────────┘