> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# use_* 会话设置

> use_* 分组中的 ClickHouse 会话设置。

export const SettingsInfoBlock = ({type, default_value, changeable_without_restart}) => {
  return <div className="not-prose" style={{
    display: "flex",
    flexWrap: "wrap",
    alignItems: "baseline",
    columnGap: "0.5rem",
    rowGap: "0.125rem",
    margin: "0.375rem 0",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <div style={{
    fontWeight: 600,
    opacity: 0.72
  }}>类型</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>默认值</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          无需重启即可更改
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

export const ExperimentalBadge = () => {
  return <div className="experimentalBadge">
            <div className="experimentalIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path strokeWidth="1.25" d="M5.5 2H10.5" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.25" d="M9.50015 2V6.19625L13.4283 12.7425C13.4738 12.8183 13.4985 12.9049 13.4996 12.9934C13.5008 13.0818 13.4785 13.169 13.435 13.246C13.3914 13.323 13.3283 13.3871 13.2519 13.4317C13.1755 13.4764 13.0886 13.4999 13.0002 13.5H3.00015C2.91164 13.5 2.8247 13.4766 2.74822 13.432C2.67174 13.3874 2.60847 13.3233 2.56487 13.2463C2.52126 13.1693 2.49889 13.082 2.50004 12.9935C2.50119 12.905 2.52582 12.8184 2.5714 12.7425L6.50015 6.19625V2" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.25" d="M4.47656 9.56754C5.30344 9.41254 6.47656 9.47942 7.99969 10.25C10.0153 11.2707 11.4216 11.0569 12.2184 10.7282" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
        </div>
            Experimental 功能。 <u><a href="/docs/docs/beta-and-experimental-features#experimental-features">了解详情。</a></u>
        </div>;
};

这些设置可在 [system.settings](/docs/zh/reference/system-tables/settings) 中查看，并由 [源代码](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) 自动生成。

<div id="use_async_executor_for_materialized_views">
  ## use\_async\_executor\_for\_materialized\_views
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.12"},{"label": "0"},{"label": "新增设置。"}]}]} />

使用异步以及可能的多线程方式执行 materialized view 查询，可在 INSERT 期间加快视图处理，但也会占用更多内存。

<div id="use_cache_for_count_from_files">
  ## use\_cache\_for\_count\_from\_files
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

启用在对表函数 `file`/`s3`/`url`/`hdfs`/`azureBlobStorage` 中的文件执行 count 时缓存行数。

默认启用。

<div id="use_client_time_zone">
  ## use\_client\_time\_zone
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

使用客户端时区来解析 DateTime 字符串值，而不是使用服务器时区。

<div id="use_compact_format_in_distributed_parts_names">
  ## use\_compact\_format\_in\_distributed\_parts\_names
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "21.1"},{"label": "1"},{"label": "默认对写入分布式表的异步 INSERT 使用紧凑格式"}]}]} />

对于使用 `Distributed` 引擎的表，后台 (`distributed_foreground_insert`) INSERT 在存储块时使用紧凑格式。

可能的值：

* 0 — 使用 `user[:password]@host:port#default_database` 目录格式。
* 1 — 使用 `[shard{shard_index}[_replica{replica_index}]]` 目录格式。

<Note>
  - 当 `use_compact_format_in_distributed_parts_names=0` 时，集群定义中的更改不会应用到后台 INSERT。
  - 当 `use_compact_format_in_distributed_parts_names=1` 时，调整集群定义中节点的顺序会改变 `shard_index`/`replica_index`，请注意。
</Note>

<div id="use_concurrency_control">
  ## use\_concurrency\_control
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.12"},{"label": "1"},{"label": "默认启用并发控制"}]}]} />

遵守服务器的并发控制 (参见全局服务器设置 `concurrent_threads_soft_limit_num` 和 `concurrent_threads_soft_limit_ratio_to_cores`) 。如果禁用，即使服务器已过载，也允许使用更多线程 (不建议在正常使用场景下这样做，通常仅测试时才需要) 。

<div id="use_constant_folding_in_index_analysis">
  ## use\_constant\_folding\_in\_index\_analysis
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.7"},{"label": "0"},{"label": "新增设置：在 MergeTree 索引分析期间，将分区级常量按每个 分片 折叠到过滤谓词中，从而改进对分支依赖分区值的过滤器的剪枝效果。"}]}]} />

在按每个 分片 分析主键和跳过索引时，将分区级常量代入过滤谓词。

当分区键与主键列或跳过索引列同时出现在过滤器中时，这会让索引分析在每个 分片 内分别折叠分区值。它对各个分支分别针对不同分区的析取过滤器尤其有用。例如，在使用 `PARTITION BY a` 和 `ORDER BY b` 时：

```sql theme={null}
SELECT * FROM t WHERE (a = 1 AND b >= 1) OR (a = 2 AND b > 10) OR (a = 3 AND b > 10)
```

对于分区 `a = 1` 中的分片，条件可折叠为 `b >= 1`；而对于分区 `a = 2` 和 `a = 3` 中的分片，则可折叠为 `b > 10`，因此会根据实际适用于每个分片的谓词分别进行分析。

可选值：

* 0 — 禁用。
* 1 — 启用。

<div id="use_hash_table_stats_for_join_reordering">
  ## use\_hash\_table\_stats\_for\_join\_reordering
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.1"},{"label": "1"},{"label": "新设置。此前与 'collect_hash_table_stats_during_joins' 设置保持一致。"}]}]} />

启用在 JOIN 重排序期间使用已收集的哈希表统计信息进行基数估算

<div id="use_hedged_requests">
  ## use\_hedged\_requests
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "21.9"},{"label": "1"},{"label": "默认启用 Hedged Requests 功能"}]}]} />

启用远程查询的 hedged requests 逻辑。这样在执行查询时，可以与不同副本建立多个连接。
如果与副本的现有连接未能在 `hedged_connection_timeout` 内建立，
或在 `receive_data_timeout` 内未收到任何数据，则会启用新连接。查询会使用第一个发送非空 Progress packet 的连接 (或者在 `allow_changing_replica_until_first_data_packet` 的情况下，使用第一个发送 data packet 的连接) ；
其他连接会被取消。支持 `max_parallel_replicas > 1` 的查询。

默认启用。

Cloud 默认值：`0`。

<div id="use_hive_partitioning">
  ## use\_hive\_partitioning
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.1"},{"label": "1"},{"label": "默认启用此设置。"}]}, {"id": "row-2","items": [{"label": "24.8"},{"label": "0"},{"label": "允许在 File、URL、S3、AzureBlobStorage 和 HDFS 引擎中使用 Hive 风格分区。"}]}]} />

启用后，ClickHouse 会在类文件表引擎 [File](/docs/zh/reference/functions/table-functions/file#hive-style-partitioning)/[S3](/docs/zh/reference/functions/table-functions/s3#hive-style-partitioning)/[URL](/docs/zh/reference/functions/table-functions/url#hive-style-partitioning)/[HDFS](/docs/zh/reference/functions/table-functions/hdfs#hive-style-partitioning)/[AzureBlobStorage](/docs/zh/reference/functions/table-functions/azureBlobStorage#hive-style-partitioning) 的路径 (`/name=value/`) 中检测 Hive 风格分区，并允许在查询中将分区列作为虚拟列使用。这些虚拟列的名称与分区路径中的名称相同，但会以下划线 `_` 开头。

<div id="use_join_disjunctions_push_down">
  ## use\_join\_disjunctions\_push\_down
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.1"},{"label": "1"},{"label": "启用此优化。"}]}, {"id": "row-2","items": [{"label": "25.10"},{"label": "0"},{"label": "新增设置。"}]}]} />

启用将 JOIN 条件中由 或 连接的各部分下推到对应输入侧 (“部分下推”) 。
这样可使存储引擎更早执行过滤，从而减少读取的数据量。
该优化不会改变语义，并且仅在每个顶层 或 分支都至少为目标侧提供一个确定性
谓词时才会应用。

<div id="use_legacy_to_time">
  ## use\_legacy\_to\_time
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.7"},{"label": "0"},{"label": "默认使用新的 `toTime` 函数（将值转换为 `Time` 数据类型），而不是旧版 `toTime`（后者仍可通过 `toTimeWithFixedDate` 使用）。"}]}, {"id": "row-2","items": [{"label": "25.6"},{"label": "1"},{"label": "新设置。允许用户对 `toTime` 使用旧版函数逻辑，其行为与 `toTimeWithFixedDate` 相同。"}]}]} />

启用后，可使用旧版 `toTime` 函数。该函数会将日期时间转换为某个固定日期，同时保留时间部分。
否则，将使用新的 `toTime` 函数，把不同类型的数据转换为 `Time` 类型。
旧版函数也始终可直接通过 `toTimeWithFixedDate` 访问。

<div id="use_lightweight_primary_key_index_analysis">
  ## use\_lightweight\_primary\_key\_index\_analysis
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.6"},{"label": "1"},{"label": "新增设置，用于优化具有较长主键的表的主键索引分析"}]}]} />

优化具有较长主键的 `MergeTree` 表的主键索引分析。

启用后，索引分析的运行时间主要取决于查询过滤器的复杂度 (即实际使用到的键列) ，而不是主键长度。因此，对于只按其中少数列进行过滤的查询，扩展排序键几乎不会给索引分析带来额外开销。

可能的值：

* 0 — 已禁用。索引分析期间会处理所有主键列。
* 1 — 已启用。

<div id="use_parquet_metadata_cache">
  ## use\_parquet\_metadata\_cache
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.3"},{"label": "1"},{"label": "启用 Parquet 文件元数据缓存。"}]}]} />

如果启用，Parquet 格式可使用 Parquet 元数据缓存。

可能的值：

* 0 - 已禁用
* 1 - 已启用

<div id="use_primary_key">
  ## use\_primary\_key
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.1"},{"label": "1"},{"label": "用于控制 MergeTree 是否使用主键进行粒度级剪枝的新设置。"}]}]} />

在查询执行期间，使用主键对 MergeTree 表的粒度进行剪枝。

可能的值：

* 0 — 已禁用。
* 1 — 已启用。

<div id="use_reader_executor">
  ## use\_reader\_executor
</div>

<ExperimentalBadge />

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.6"},{"label": "0"},{"label": "新增 Experimental 设置：将读取通过新的管道 `ReaderExecutor` 进行路由，而不是使用传统的多层读取缓冲区嵌套结构。"}]}]} />

实验性功能。将读取通过新的管道 `ReaderExecutor` 进行路由，而不是使用传统的多层读取缓冲区嵌套结构。对于执行器尚未支持的配置，会回退到传统路径。

<div id="use_roaring_bitmap_iceberg_positional_deletes">
  ## use\_roaring\_bitmap\_iceberg\_positional\_deletes
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.8"},{"label": "0"},{"label": "新增设置"}]}]} />

对 Iceberg 位置删除使用 roaring bitmap。

<div id="use_streaming_marks_compression">
  ## use\_streaming\_marks\_compression
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.7"},{"label": "0"},{"label": "新增设置：将 marks 逐块（流式）压缩为内存中的表示，而不是先物化完整的原始 marks 数组，从而在为包含许多 substreams 的 compact 分片 加载 marks 时降低峰值内存占用。"}]}]} />

在为 MergeTree 分片 加载 marks 时，将其逐块 (流式) 压缩为内存中的表示，而不是先物化完整的原始 marks 数组。这会显著降低为包含许多 substreams 的 compact 分片 加载 marks 时的峰值内存占用 (例如包含 JSON 列且启用了 `write_marks_for_substreams_in_compact_parts` 的表) 。

<div id="use_strict_insert_block_limits">
  ## use\_strict\_insert\_block\_limits
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.4"},{"label": "0"},{"label": "新增设置，用于在插入时严格应用最小和最大插入边界。当 min < max 时，max 限制具有优先次序。"}]}]} />

启用后，会严格执行最小和最大插入块大小限制。

在以下情况下会输出一个块：

* 最小阈值 (与) ：同时达到 min\_insert\_block\_size\_rows AND min\_insert\_block\_size\_bytes。
* 最大阈值 (或) ：达到 max\_insert\_block\_size\_rows 或 max\_insert\_block\_size\_bytes 中任意一个。

禁用后，在以下情况下会输出一个块：

* 最小阈值 (或) ：达到 min\_insert\_block\_size\_rows 或 min\_insert\_block\_size\_bytes 中任意一个。

**注**：如果 max 设置小于 min 设置，则 max 限制具有优先次序，块会在达到最小阈值之前输出。

**注**：对于异步插入，此设置会自动禁用，因为异步插入会为每个条目附加去重标记，而这与执行严格限制所需的块拆分不兼容。

默认禁用。

<div id="use_structure_from_insertion_table_in_table_functions">
  ## use\_structure\_from\_insertion\_table\_in\_table\_functions
</div>

<SettingsInfoBlock type="UInt64" default_value="2" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "22.11"},{"label": "2"},{"label": "改进在表函数中使用插入表结构的功能"}]}]} />

使用插入表的结构，而不是根据数据自动推断 schema。可选值：0 - 禁用，1 - 启用，2 - 自动

<div id="use_uncompressed_cache">
  ## use\_uncompressed\_cache
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

是否使用未压缩块缓存。可选值为 0 或 1。默认值为 0 (禁用) 。
使用未压缩缓存 (仅适用于 MergeTree 家族中的表) 可以在处理大量短查询时显著降低延迟并提高吞吐量。对于频繁发送短请求的用户，建议启用此设置。同时还要注意 [uncompressed\_cache\_size](/docs/zh/reference/settings/server-settings/settings#uncompressed_cache_size) 配置参数 (只能在配置文件中设置) ——它指定未压缩缓存块的大小。默认值为 8 GiB。未压缩缓存会按需填充，并自动删除使用频率最低的数据。

对于读取的数据量较大的查询 (100 万行或更多) ，系统会自动禁用未压缩缓存，以便为真正的小查询节省空间。这意味着你可以始终将 `use_uncompressed_cache` 设为 1。

<div id="use_with_fill_by_sorting_prefix">
  ## use\_with\_fill\_by\_sorting\_prefix
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "23.5"},{"label": "1"},{"label": "在 ORDER BY 子句中，位于 WITH FILL 列之前的列构成排序前缀。对于排序前缀值不同的行，将分别独立填充"}]}]} />

在 ORDER BY 子句中，位于 WITH FILL 列之前的列构成排序前缀。对于排序前缀值不同的行，将分别独立填充
