Invert config parameter name for more clarity

This commit is contained in:
Robert Schulze 2022-12-17 14:46:00 +00:00
parent fe5cd9e601
commit aa50b9cf48
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
8 changed files with 12 additions and 14 deletions

View File

@ -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).

View File

@ -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}

View File

@ -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) \

View File

@ -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;
}

View File

@ -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.
///

View File

@ -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(),

View File

@ -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

View File

@ -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;