メインコンテンツまでスキップ
メインコンテンツまでスキップ

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