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

# query_cache_* セッション設定

> query_cache_* の自動生成グループに含まれる ClickHouse のセッション設定。

export const VersionHistory = ({rows = []}) => {
  if (rows.length === 0) {
    return null;
  }
  const headers = ["バージョン", "デフォルト値", "コメント"];
  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
  }}>
        バージョン履歴
      </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
  }}>型</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](/ja/reference/system-tables/settings) で参照でき、[ソース](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) から自動生成されています。

<div id="query_cache_compress_entries">
  ## query\_cache\_compress\_entries
</div>

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

[クエリキャッシュ](/ja/concepts/features/performance/caches/query-cache)内のエントリを圧縮します。これにより、クエリキャッシュのメモリ使用量は削減されますが、クエリキャッシュへの挿入やクエリキャッシュからの読み取りは遅くなります。

設定可能な値:

* 0 - 無効
* 1 - 有効

<div id="query_cache_for_subqueries">
  ## query\_cache\_for\_subqueries
</div>

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

有効にすると、サブクエリの結果が [query cache](/ja/concepts/features/performance/caches/query-cache) に書き込まれたり、そこから読み込まれたりするようになります。これにより、`use_query_cache` がすべてのサブクエリに伝播されます。

設定可能な値:

* 0 - 無効
* 1 - 有効

<div id="query_cache_max_entries">
  ## query\_cache\_max\_entries
</div>

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

現在のユーザーが [クエリキャッシュ](/ja/concepts/features/performance/caches/query-cache) に保存できるクエリ結果の最大件数です。0 は無制限を意味します。

設定可能な値:

* 0 以上の整数。

<div id="query_cache_max_size_in_bytes">
  ## query\_cache\_max\_size\_in\_bytes
</div>

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

現在のユーザーが [クエリキャッシュ](/ja/concepts/features/performance/caches/query-cache) に割り当てられるメモリの最大量 (バイト単位) 。0 は無制限を意味します。

設定可能な値:

* 0 以上の整数。

<div id="query_cache_min_query_duration">
  ## query\_cache\_min\_query\_duration
</div>

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

クエリの結果を[クエリキャッシュ](/ja/concepts/features/performance/caches/query-cache)に保存するために、そのクエリが実行されている必要がある最小時間 (ミリ秒単位) 。

設定可能な値:

* 0 以上の整数。

<div id="query_cache_min_query_runs">
  ## query\_cache\_min\_query\_runs
</div>

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

[query cache](/ja/concepts/features/performance/caches/query-cache) に結果が保存されるまでに、`SELECT` クエリが実行される必要がある最小回数。

設定可能な値:

* 0 以上の整数。

<div id="query_cache_nondeterministic_function_handling">
  ## query\_cache\_nondeterministic\_function\_handling
</div>

<SettingsInfoBlock type="QueryResultCacheNondeterministicFunctionHandling" default_value="throw" />

`rand()` や `now()` などの非決定論的関数を含む `SELECT` クエリを、[query cache](/ja/concepts/features/performance/caches/query-cache) がどのように扱うかを制御します。

設定可能な値:

* `'throw'` - 例外をスローし、クエリ結果を cache しません。
* `'save'` - クエリ結果を cache します。
* `'ignore'` - クエリ結果を cache せず、例外もスローしません。

<div id="query_cache_share_between_users">
  ## query\_cache\_share\_between\_users
</div>

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

有効にすると、[クエリキャッシュ](/ja/concepts/features/performance/caches/query-cache)にキャッシュされた`SELECT`クエリの結果を、他のユーザーも参照できるようになります。
セキュリティ上の理由から、この設定を有効にすることは推奨されません。

設定可能な値:

* 0 - 無効
* 1 - 有効

<div id="query_cache_squash_partial_results">
  ## query\_cache\_squash\_partial\_results
</div>

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

部分的な結果ブロックを、サイズが [max\_block\_size](/ja/reference/settings/session-settings/max#max_block_size) のブロックにまとめます。[query cache](/ja/concepts/features/performance/caches/query-cache) への挿入のパフォーマンスは低下しますが、cache エントリの圧縮効率は向上します ([query\_cache\_compress-entries](/ja/reference/settings/session-settings/query-cache#query_cache_compress_entries) を参照) 。

設定可能な値:

* 0 - 無効
* 1 - 有効

<div id="query_cache_system_table_handling">
  ## query\_cache\_system\_table\_handling
</div>

<SettingsInfoBlock type="QueryResultCacheSystemTableHandling" default_value="throw" />

[クエリキャッシュ](/ja/concepts/features/performance/caches/query-cache) がシステムテーブル、つまり `system.*` および `information_schema.*` データベース内のテーブルに対する `SELECT` クエリをどのように扱うかを制御します。

設定可能な値:

* `'throw'` - 例外をスローし、クエリ結果をキャッシュしません。
* `'save'` - クエリ結果をキャッシュします。
* `'ignore'` - クエリ結果をキャッシュせず、例外もスローしません。

<div id="query_cache_tag">
  ## query\_cache\_tag
</div>

[query cache](/ja/concepts/features/performance/caches/query-cache) のエントリに付けるラベルとして機能する文字列です。
タグが異なる同じクエリは、query cache では別のものとして扱われます。

設定可能な値:

* 任意の文字列

<div id="query_cache_ttl">
  ## query\_cache\_ttl
</div>

<SettingsInfoBlock type="Seconds" default_value="60" />

指定した秒数を過ぎると、[query cache](/ja/concepts/features/performance/caches/query-cache) 内のエントリは古いものと見なされます。

設定可能な値:

* 0 以上の整数。
