Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

query_cache_* session settings

These settings are available in system.settings and are autogenerated from source.

query_cache_compress_entries

Type
Bool
Default
1

Compress entries in the query cache. Lessens the memory consumption of the query cache at the cost of slower inserts into / reads from it.

Possible values:

  • 0 - Disabled
  • 1 - Enabled

query_cache_for_subqueries

Type
Bool
Default
0
Version history
VersionDefault valueComment
26.50New setting to enable propagation of `use_query_cache` into all subqueries. Without it, subqueries are only cached on explicit per-subquery `SETTINGS use_query_cache = true` opt-in.

If turned on, subquery results may be written to and read from the query cache. This enables propagation of use_query_cache into all subqueries.

Possible values:

  • 0 - Disabled
  • 1 - Enabled

query_cache_max_entries

Type
UInt64
Default
0

The maximum number of query results the current user may store in the query cache. 0 means unlimited.

Possible values:

  • Positive integer >= 0.

query_cache_max_size_in_bytes

Type
UInt64
Default
0

The maximum amount of memory (in bytes) the current user may allocate in the query cache. 0 means unlimited.

Possible values:

  • Positive integer >= 0.

query_cache_min_query_duration

Type
Milliseconds
Default
0

Minimum duration in milliseconds a query needs to run for its result to be stored in the query cache.

Possible values:

  • Positive integer >= 0.

query_cache_min_query_runs

Type
UInt64
Default
0

Minimum number of times a SELECT query must run before its result is stored in the query cache.

Possible values:

  • Positive integer >= 0.

query_cache_nondeterministic_function_handling

Type
QueryResultCacheNondeterministicFunctionHandling
Default
throw

Controls how the query cache handles SELECT queries with non-deterministic functions like rand() or now().

Possible values:

  • 'throw' - Throw an exception and don’t cache the query result.
  • 'save' - Cache the query result.
  • 'ignore' - Don’t cache the query result and don’t throw an exception.

query_cache_share_between_users

Type
Bool
Default
0

If turned on, the result of SELECT queries cached in the query cache can be read by other users. It is not recommended to enable this setting due to security reasons.

Possible values:

  • 0 - Disabled
  • 1 - Enabled

query_cache_squash_partial_results

Type
Bool
Default
1

Squash partial result blocks to blocks of size max_block_size. Reduces performance of inserts into the query cache but improves the compressability of cache entries (see query_cache_compress-entries).

Possible values:

  • 0 - Disabled
  • 1 - Enabled

query_cache_system_table_handling

Type
QueryResultCacheSystemTableHandling
Default
throw
Version history
VersionDefault valueComment
24.4throwThe query cache no longer caches results of queries against system tables

Controls how the query cache handles SELECT queries against system tables, i.e. tables in databases system.* and information_schema.*.

Possible values:

  • 'throw' - Throw an exception and don’t cache the query result.
  • 'save' - Cache the query result.
  • 'ignore' - Don’t cache the query result and don’t throw an exception.

query_cache_tag

Version history
VersionDefault valueComment
24.8New setting for labeling query cache settings.

A string which acts as a label for query cache entries. The same queries with different tags are considered different by the query cache.

Possible values:

  • Any string

query_cache_ttl

Type
Seconds
Default
60

After this time in seconds entries in the query cache become stale.

Possible values:

  • Positive integer >= 0.
Navigation