mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 01:00:48 +00:00
Invert config parameter name for more clarity
This commit is contained in:
parent
fe5cd9e601
commit
aa50b9cf48
@ -71,7 +71,7 @@ To control how often a query needs to run until its result is cached, use settin
|
||||
|
||||
To specify the validity period after which cache entries become stale, use setting [query_result_cache_keep_seconds_alive](settings/settings.md#query-result-cache-keep-seconds-alive).
|
||||
|
||||
Results of queries with non-deterministic functions such as `rand()` and `now()` are not cached by default. This behavior can be overruled using setting [query_result_cache_ignore_nondeterministic_functions](settings/settings.md#query-result-cache-ignore-nondeterministic-functions).
|
||||
Results of queries with non-deterministic functions such as `rand()` and `now()` are not cached by default. This behavior can be overruled using setting [query_result_cache_store_results_of_queries_with_nondeterministic_functions](settings/settings.md#query-result-cache-store-results-of-queries-with-nondeterministic-functions).
|
||||
|
||||
Finally, it is sometimes useful to cache query results of the same query multiple times with different validity periods. To identify
|
||||
different entries for the same query, users may pass configuration [query_result_cache_partition_key](settings/settings.md#query-result-cache-partition-key).
|
||||
|
@ -1192,16 +1192,16 @@ Possible values:
|
||||
|
||||
Default value: `0`.
|
||||
|
||||
## query_result_cache_ignore_nondeterministic_functions {#experimental-query-result-cache-ignore-nondeterministic-function}
|
||||
## query_result_cache_store_results_of_queries_with_nondeterministic_functions {#query-result-cache-store-results-of-queries-with-nondeterministic-functions}
|
||||
|
||||
If turned on, then results of SELECT queries with non-deterministic functions (e.g. `rand()`, `now()`) are not cached in the [query result cache](../query-result-cache.md).
|
||||
If turned on, then results of SELECT queries with non-deterministic functions (e.g. `rand()`, `now()`) can be cached in the [query result cache](../query-result-cache.md).
|
||||
|
||||
Possible values:
|
||||
|
||||
- 0 - Disabled
|
||||
- 1 - Enabled
|
||||
|
||||
Default value: `1`.
|
||||
Default value: `0`.
|
||||
|
||||
## query_result_cache_min_query_runs {#query-result-cache-min-query-runs}
|
||||
|
||||
|
@ -673,7 +673,7 @@ static constexpr UInt64 operator""_GiB(unsigned long long value)
|
||||
M(Bool, optimize_sorting_by_input_stream_properties, true, "Optimize sorting by sorting properties of input stream", 0) \
|
||||
M(Bool, enable_experimental_query_result_cache, false, "Store and retrieve results of SELECT queries in/from the query result cache", 0) \
|
||||
M(Bool, enable_experimental_query_result_cache_passive_usage, false, "Only retrieve results of SELECT queries from the query result cache", 0) \
|
||||
M(Bool, query_result_cache_ignore_nondeterministic_functions, true, "Queries with non-deterministic functions (e.g. rand(), now()) are not stored in the query result cache", 0) \
|
||||
M(Bool, query_result_cache_store_results_of_queries_with_nondeterministic_functions, false, "Store results of queries with non-deterministic functions (e.g. rand(), now()) in the query result cache", 0) \
|
||||
M(UInt64, query_result_cache_size, (1ull << 30), "Maximum size of the query result cache in bytes. 0 means disabled.", 0) \
|
||||
M(UInt64, query_result_cache_min_query_runs, 0, "Minimum number a SELECT query must run before its result is stored in the query result cache", 0) \
|
||||
M(UInt64, query_result_cache_max_entries, (1ull << 10), "Maximum number of SELECT query results in the query result cache", 0) \
|
||||
|
@ -17,11 +17,8 @@ namespace ProfileEvents
|
||||
namespace DB
|
||||
{
|
||||
|
||||
bool hasNonCacheableFunctions(ASTPtr ast, ContextPtr context)
|
||||
bool astContainsNonDeterministicFunctions(ASTPtr ast, ContextPtr context)
|
||||
{
|
||||
if (!context->getSettings().query_result_cache_ignore_nondeterministic_functions)
|
||||
return false;
|
||||
|
||||
if (const auto * function = ast->as<ASTFunction>())
|
||||
{
|
||||
const FunctionFactory & function_factory = FunctionFactory::instance();
|
||||
@ -34,7 +31,7 @@ bool hasNonCacheableFunctions(ASTPtr ast, ContextPtr context)
|
||||
|
||||
bool has_non_cacheable_functions = false;
|
||||
for (const auto & child : ast->children)
|
||||
has_non_cacheable_functions |= hasNonCacheableFunctions(child, context);
|
||||
has_non_cacheable_functions |= astContainsNonDeterministicFunctions(child, context);
|
||||
|
||||
return has_non_cacheable_functions;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace DB
|
||||
{
|
||||
|
||||
/// Does AST contain non-deterministic functions like rand() and now()?
|
||||
bool hasNonCacheableFunctions(ASTPtr ast, ContextPtr context);
|
||||
bool astContainsNonDeterministicFunctions(ASTPtr ast, ContextPtr context);
|
||||
|
||||
/// Maps queries to query results. Useful to avoid repeated query calculation.
|
||||
///
|
||||
|
@ -700,7 +700,8 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
|
||||
}
|
||||
|
||||
if ((settings.enable_experimental_query_result_cache_passive_usage || settings.enable_experimental_query_result_cache)
|
||||
&& query_result_cache != nullptr && res.pipeline.pulling() && !hasNonCacheableFunctions(ast, context))
|
||||
&& query_result_cache != nullptr && res.pipeline.pulling()
|
||||
&& (settings.query_result_cache_store_results_of_queries_with_nondeterministic_functions || !astContainsNonDeterministicFunctions(ast, context)))
|
||||
{
|
||||
QueryResultCache::Key key{
|
||||
ast, context->getUserName(), settings.query_result_cache_partition_key, res.pipeline.getHeader(),
|
||||
|
@ -7,7 +7,7 @@ SELECT COUNT(rand(1)) SETTINGS enable_experimental_query_result_cache = true;
|
||||
SELECT COUNT(*) FROM system.queryresult_cache;
|
||||
0
|
||||
-- force an entry
|
||||
SELECT COUNT(RAND(1)) SETTINGS enable_experimental_query_result_cache = true, query_result_cache_ignore_nondeterministic_functions = false;
|
||||
SELECT COUNT(RAND(1)) SETTINGS enable_experimental_query_result_cache = true, query_result_cache_store_results_of_queries_with_nondeterministic_functions = true;
|
||||
1
|
||||
SELECT COUNT(*) FROM system.queryresult_cache;
|
||||
1
|
@ -7,7 +7,7 @@ SELECT COUNT(rand(1)) SETTINGS enable_experimental_query_result_cache = true;
|
||||
SELECT COUNT(*) FROM system.queryresult_cache;
|
||||
|
||||
-- force an entry
|
||||
SELECT COUNT(RAND(1)) SETTINGS enable_experimental_query_result_cache = true, query_result_cache_ignore_nondeterministic_functions = false;
|
||||
SELECT COUNT(RAND(1)) SETTINGS enable_experimental_query_result_cache = true, query_result_cache_store_results_of_queries_with_nondeterministic_functions = true;
|
||||
SELECT COUNT(*) FROM system.queryresult_cache;
|
||||
|
||||
SYSTEM DROP QUERY RESULT CACHE;
|
Loading…
Reference in New Issue
Block a user