> ## 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_* session settings

> ClickHouse session settings in the replace_running_query_* generated group.

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
  }}>Type</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>Default</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          Changeable without restart
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

These settings are available in [system.settings](/docs/reference/system-tables/settings) and are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp).

<h2 id="replace_running_query">
  replace\_running\_query
</h2>

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

When using the HTTP interface, the 'query\_id' parameter can be passed. This is any string that serves as the query identifier.
If a query from the same user with the same 'query\_id' already exists at this time, the behaviour depends on the 'replace\_running\_query' parameter.

`0` (default) – Throw an exception (do not allow the query to run if a query with the same 'query\_id' is already running).

`1` – Cancel the old query and start running the new one.

Set this parameter to 1 for implementing suggestions for segmentation conditions. After entering the next character, if the old query hasn't finished yet, it should be cancelled.

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

<SettingsInfoBlock type="Milliseconds" default_value="5000" />

The wait time for running the query with the same `query_id` to finish, when the [replace\_running\_query](/docs/reference/settings/session-settings/replace-running-query#replace_running_query) setting is active.

Possible values:

* Positive integer.
* 0 — Throwing an exception that does not allow to run a new query if the server already executes a query with the same `query_id`.
