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

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