estimateCompressionRatio

estimateCompressionRatio

주어진 컬럼을 실제로 압축하지 않고도 압축 비율(compression ratio)을 추정해 주는 집계 함수예요. 데이터 타입과 분포에 따라 대략 어느 정도 줄어들지 미리 가늠해 볼 수 있습니다.

출처: 문서

본문

도입 버전: v25.4.0

주어진 컬럼을 압축하지 않고 그 압축 비율을 추정합니다.

참고: 아래 예제들의 결과는 서버의 기본 압축 코덱에 따라 달라집니다. 컬럼 압축 코덱 (Column Compression Codecs)을 참고하세요.

구문 (Syntax)

estimateCompressionRatio([codec, block_size_bytes])(column)

파라미터 (Parameters)

  • codec — 압축 코덱을 담은 문자열. 하나의 문자열 안에 쉼표로 구분된 여러 코덱을 넣을 수도 있습니다. String
  • block_size_bytes — 압축 데이터의 블록 크기. max_compress_block_sizemin_compress_block_size 둘 다 설정하는 것과 비슷합니다. 기본값은 1 MiB(1048576 바이트)이고, 허용 최대값은 256 MiB(268435456 바이트)입니다. UInt64

인자 (Arguments)

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

특정 코덱 사용

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

더 알아보기 (Learn more)