Skip to main content
These settings are available in system.settings and are autogenerated from source.

query_cache_compress_entries

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

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

The maximum number of query results the current user may store in the in-memory query cache. 0 means unlimited. This limit does not apply to the query cache on disk (setting query_cache_on_disk_cache_name), whose entries are bounded by the size of the underlying filesystem cache instead. Possible values:
  • Positive integer >= 0.

query_cache_max_size_in_bytes

The maximum amount of memory (in bytes) the current user may allocate in the in-memory query cache. 0 means unlimited. This limit does not apply to the query cache on disk (setting query_cache_on_disk_cache_name), whose entries are bounded by the size of the underlying filesystem cache instead. Possible values:
  • Positive integer >= 0.

query_cache_min_query_duration

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

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

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_on_disk_cache_name

The name of a filesystem cache (an entry of the filesystem_caches section of the server configuration) which stores entries of the query cache on disk. If a name is given (and use_query_cache is enabled), query results are additionally cached in (and served from) the specified filesystem cache. The on-disk query cache provides more space than the in-memory query cache, survives server restarts, and works independently of the in-memory query cache: settings enable_reads_from_query_cache_on_disk and enable_writes_to_query_cache_on_disk control it separately from the in-memory query cache. The entries in the filesystem cache are ordinary entries of the filesystem cache: they are not held from deletion and they are evicted by the same rules as any other data in it. SYSTEM CLEAR FILESYSTEM CACHE '<name>' removes them together with everything else in the filesystem cache, and SYSTEM CLEAR QUERY CACHE removes the entries of the query cache on disk from the filesystem cache named by this setting, leaving all other data in place. A dedicated filesystem cache for query results is recommended. Possible values:
  • Empty string - The query cache on disk is disabled
  • The name of a preconfigured filesystem cache

query_cache_on_disk_codec

The compression codec for entries of the query cache on disk (see query_cache_on_disk_cache_name). Only affects writing; reading is independent of this setting because the compressed data is self-describing.

query_cache_share_between_users

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

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

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

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

After this time in seconds entries in the query cache become stale. Possible values:
  • Positive integer >= 0.
Last modified on October 8, 2026