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

# query_cache_* セッション設定

> query_cache_* の自動生成グループに含まれる 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>;
};

これらの設定は [system.settings](/docs/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" />

[クエリキャッシュ](/docs/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" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.5"},{"label": "0"},{"label": "`use_query_cache` をすべてのサブクエリに伝播させるための新しい設定です。これがない場合、サブクエリが cache されるのは、サブクエリごとに明示的に `SETTINGS use_query_cache = true` を指定した場合のみです。"}]}]} />

有効にすると、サブクエリの結果が [query cache](/docs/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" />

現在のユーザーが [クエリキャッシュ](/docs/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" />

現在のユーザーが [クエリキャッシュ](/docs/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" />

クエリの結果を[クエリキャッシュ](/docs/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](/docs/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](/docs/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" />

有効にすると、[クエリキャッシュ](/docs/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](/docs/ja/reference/settings/session-settings/max#max_block_size) のブロックにまとめます。[query cache](/docs/ja/concepts/features/performance/caches/query-cache) への挿入のパフォーマンスは低下しますが、cache エントリの圧縮効率は向上します ([query\_cache\_compress-entries](/docs/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" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.4"},{"label": "throw"},{"label": "query cache はシステムテーブルに対するクエリ結果をキャッシュしなくなりました"}]}]} />

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

設定可能な値:

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

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.8"},{"label": ""},{"label": "query cache にラベルを付けるための新しい設定。"}]}]} />

[query cache](/docs/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](/docs/ja/concepts/features/performance/caches/query-cache) 内のエントリは古いものと見なされます。

設定可能な値:

* 0 以上の整数。
