> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-3a82795f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 在不实际压缩给定列的情况下，估算其压缩率。

# estimateCompressionRatio

<div id="estimateCompressionRatio">
  ## estimateCompressionRatio
</div>

Introduced in：v25.4.0

在不实际压缩给定列的情况下，估算其压缩率。

<Note>
  对于下面的示例，结果会因服务器默认的压缩编解码器不同而有所差异。
  请参阅 [列压缩编解码器](/zh/reference/statements/create/table#column_compression_codec)。
</Note>

**语法**

```sql theme={null}
estimateCompressionRatio([codec, block_size_bytes])(column)
```

**参数**

* `codec` — 包含一个压缩编解码器，或多个以逗号分隔的编解码器的 String。[`String`](/zh/reference/data-types/string)
* `block_size_bytes` — 压缩数据的块大小。这类似于同时设置 [`max_compress_block_size`](/zh/reference/settings/merge-tree-settings#max_compress_block_size) 和 [`min_compress_block_size`](/zh/reference/settings/merge-tree-settings#min_compress_block_size)。默认值为 1 MiB (1048576 字节) 。允许的最大值为 256 MiB (268435456 字节) 。[`UInt64`](/zh/reference/data-types/int-uint)

**参数说明**

* `column` — 任意类型的列。[`Any`](/zh/reference/data-types)

**返回值**

返回给定列的压缩率估计值。[`Float64`](/zh/reference/data-types/float)

**示例**

**默认编解码器的基本用法**

```sql title=Query theme={null}
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
```

```response title=Response theme={null}
┌───────────estimate─┐
│ 1.9988506608699999 │
└────────────────────┘
```

**使用特定编解码器**

```sql title=Query theme={null}
SELECT estimateCompressionRatio('T64')(number) AS estimate FROM compression_estimate_example
```

```response title=Response theme={null}
┌──────────estimate─┐
│ 3.762758101688538 │
└───────────────────┘
```

**使用多种编解码器**

```sql title=Query theme={null}
SELECT estimateCompressionRatio('T64, ZSTD')(number) AS estimate FROM compression_estimate_example
```

```response title=Response theme={null}
┌───────────estimate─┐
│ 143.60078980434392 │
└────────────────────┘
```
