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

# max_temporary_* session settings

> ClickHouse session settings in the max_temporary_* generated group.

export const VersionHistory = ({rows = []}) => {
  if (rows.length === 0) {
    return null;
  }
  const headers = ["Version", "Default value", "Comment"];
  const border = "1px solid rgba(128, 128, 128, 0.3)";
  const cell = {
    border,
    padding: "0.25rem 0.5rem",
    textAlign: "start",
    verticalAlign: "top"
  };
  return <details className="not-prose" style={{
    border,
    borderRadius: "0.5rem",
    margin: "0.5rem 0",
    padding: "0.5rem 0.75rem",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <summary style={{
    cursor: "pointer",
    fontWeight: 600,
    opacity: 0.72
  }}>
        Version history
      </summary>
      <table style={{
    borderCollapse: "collapse",
    width: "100%",
    margin: "0.5rem 0 0"
  }}>
        <thead>
          <tr>
            {headers.map(header => <th key={header} style={{
    ...cell,
    fontWeight: 600,
    opacity: 0.72
  }}>
                {header}
              </th>)}
          </tr>
        </thead>
        <tbody>
          {rows.map((row, row_index) => <tr key={row.id ?? row_index}>
              {(row.items ?? []).map((item, item_index) => <td key={item_index} style={{
    ...cell,
    overflowWrap: "anywhere"
  }}>
                  {item?.label}
                </td>)}
            </tr>)}
        </tbody>
      </table>
    </details>;
};

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](/reference/system-tables/settings) and are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp).

<h2 id="max_temporary_columns">
  max\_temporary\_columns
</h2>

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

The maximum number of temporary columns that must be kept in RAM simultaneously
when running a query, including constant columns. If a query generates more than
the specified number of temporary columns in memory as a result of intermediate
calculation, then an exception is thrown.

<Tip>
  This setting is useful for preventing overly complex queries.
</Tip>

`0` value means unlimited.

<h2 id="max_temporary_data_on_disk_size_for_query">
  max\_temporary\_data\_on\_disk\_size\_for\_query
</h2>

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

The maximum amount of data consumed by temporary files on disk in bytes for all
concurrently running queries.

Possible values:

* Positive integer.
* `0` — unlimited (default)

<h2 id="max_temporary_data_on_disk_size_for_user">
  max\_temporary\_data\_on\_disk\_size\_for\_user
</h2>

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

The maximum amount of data consumed by temporary files on disk in bytes for all
concurrently running user queries.

Possible values:

* Positive integer.
* `0` — unlimited (default)

<h2 id="max_temporary_non_const_columns">
  max\_temporary\_non\_const\_columns
</h2>

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

Like `max_temporary_columns`, the maximum number of temporary columns that must
be kept in RAM simultaneously when running a query, but without counting constant
columns.

<Note>
  Constant columns are formed fairly often when running a query, but they require
  approximately zero computing resources.
</Note>

<h2 id="max_temporary_table_memory_usage">
  max\_temporary\_table\_memory\_usage
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.10"},{"label": "0"},{"label": "New setting to limit the memory usage of a temporary table with the `Memory` engine."}]}]} />

The maximum number of bytes of memory that one temporary table with the `Memory` engine can hold.
It applies to tables created with `CREATE TEMPORARY TABLE`, including the default temporary table engine
(see `default_temporary_table_engine`), and is counted in the same way as `total_bytes` in `system.tables`.

The limit is checked on every `INSERT` into the table (including `CREATE TEMPORARY TABLE ... AS SELECT`), while the data
is being received and again before it is added: if the table would exceed it, the `INSERT` throws an exception with the
`TOO_MANY_BYTES` error code and the data is not added. An `INSERT` that writes with several threads (see
`max_insert_threads`) adds the data of every thread separately, so the data of some threads may already be added when
another one throws, but the table never exceeds the limit. The value is taken from the settings of the `INSERT` query.
The limit is also checked after a mutation (`ALTER TABLE ... UPDATE`, `MATERIALIZE COLUMN`, etc.), with the value from
the settings of the `ALTER` query: if the mutated data would exceed it, the mutation throws an exception with the
`TOO_MANY_BYTES` error code and the data is left unchanged.

Note that the `max_bytes_to_keep` setting of the `Memory` engine is different: it evicts the oldest data instead of
rejecting the new one. If both are set, the eviction is applied first.

Possible values:

* Positive integer.
* `0` — unlimited (default)

<h2 id="max_temporary_table_size_bytes_compressed">
  max\_temporary\_table\_size\_bytes\_compressed
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.10"},{"label": "0"},{"label": "New setting to limit the compressed size of a temporary table with an engine of the `MergeTree` family."}]}]} />

The maximum size in bytes of the data on disk (compressed) of one temporary table with an engine of the `MergeTree` family.
It applies to tables created with `CREATE TEMPORARY TABLE` and is counted in the same way as `total_bytes` in `system.tables`,
that is, as the sum of the sizes of the active data parts.

The limit is checked on every `INSERT` into the table (including `CREATE TEMPORARY TABLE ... AS SELECT`) before each new
data part is committed: if the table would exceed it, the `INSERT` throws an exception with the `TOO_MANY_BYTES` error
code and the part is not added. Parts committed earlier by the same `INSERT` stay in the table, as with any other
error during an `INSERT` of multiple blocks. The value is taken from the settings of the `INSERT` query.

The operations that add existing parts to the table are limited in the same way, with the value from the settings of
their query: `ATTACH PART`, `ATTACH PARTITION`, `ATTACH PARTITION ... FROM`, `REPLACE PARTITION ... FROM`
and `CREATE TEMPORARY TABLE ... CLONE AS`. They are rejected as a whole, unless they do
not increase the size of the table. For `ATTACH PARTITION`, the check is done once for all its parts before they are
attached, so writes running concurrently with it may make the table exceed the limit slightly.

The parts written by background merges and mutations (`ALTER TABLE ... UPDATE`,
`MATERIALIZE COLUMN`, etc.) are not checked, so a mutation that makes the data larger can make the table exceed the limit.

Possible values:

* Positive integer.
* `0` — unlimited (default)

<h2 id="max_temporary_table_size_bytes_uncompressed">
  max\_temporary\_table\_size\_bytes\_uncompressed
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.10"},{"label": "0"},{"label": "New setting to limit the uncompressed size of a temporary table with an engine of the `MergeTree` family."}]}]} />

The maximum size in bytes of the uncompressed data of one temporary table with an engine of the `MergeTree` family.
It applies to tables created with `CREATE TEMPORARY TABLE` and is counted in the same way as `total_bytes_uncompressed`
in `system.tables`.

The limit is checked in the same way as `max_temporary_table_size_bytes_compressed`.

Possible values:

* Positive integer.
* `0` — unlimited (default)

<h2 id="max_temporary_tables">
  max\_temporary\_tables
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.10"},{"label": "0"},{"label": "New setting to limit the number of temporary tables in a session."}]}]} />

The maximum number of temporary tables that can exist in one session at the same time.
Only tables created with `CREATE TEMPORARY TABLE` are counted: tables with external data sent with a query and the
temporary tables built internally for `GLOBAL IN` / `GLOBAL JOIN` or materialized CTEs are not.

The limit is checked when a new temporary table is created, and an exception with the `TOO_MANY_TABLES` error code is
thrown if the session already has this number of temporary tables. Replacing an existing temporary table with
`CREATE OR REPLACE TEMPORARY TABLE` does not increase the number of tables and is always allowed.

Possible values:

* Positive integer.
* `0` — unlimited (default)
