estimateCompressionRatio
Introduced in:v25.4.0
在不实际压缩给定列的情况下,估算其压缩率。
语法
estimateCompressionRatio([codec, block_size_bytes])(column)参数
codec— 包含一个压缩编解码器,或多个以逗号分隔的编解码器的 String。Stringblock_size_bytes— 压缩数据的块大小。这类似于同时设置max_compress_block_size和min_compress_block_size。默认值为 1 MiB (1048576 字节) 。允许的最大值为 256 MiB (268435456 字节) 。UInt64
参数说明
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 │
└────────────────────┘