> ## 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.

# replace_running_query_* 会话设置

> ClickHouse 中 replace_running_query_* 生成组的会话设置。

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>;
};

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

<div id="replace_running_query">
  ## replace\_running\_query
</div>

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

使用 HTTP 接口时，可以传递 `query_id` 参数。它可以是任意字符串，用作查询标识符。
如果此时同一用户使用相同 `query_id` 的查询已存在，其行为取决于 `replace_running_query` 参数。

`0` (默认) – 抛出异常 (如果具有相同 `query_id` 的查询已在运行，则不允许该查询运行) 。

`1` – 取消旧查询并开始运行新查询。

如需实现分群条件建议功能，请将此参数设置为 1。输入下一个字符后，如果旧查询尚未完成，则应将其取消。

<div id="replace_running_query_max_wait_ms">
  ## replace\_running\_query\_max\_wait\_ms
</div>

<SettingsInfoBlock type="毫秒" default_value="5000" />

启用 [replace\_running\_query](/docs/zh/reference/settings/session-settings/replace-running-query#replace_running_query) 设置后，如果存在相同 `query_id` 的查询正在运行，等待其结束的时间。

可能的值：

* 正整数。
* 0 — 如果服务器已经在执行具有相同 `query_id` 的查询，则抛出异常，不允许运行新的查询。
