diff --git a/src/Interpreters/executeQuery.cpp b/src/Interpreters/executeQuery.cpp index 46e3e3344cf..53fd5088372 100644 --- a/src/Interpreters/executeQuery.cpp +++ b/src/Interpreters/executeQuery.cpp @@ -1167,7 +1167,7 @@ static std::tuple executeQueryImpl( std::chrono::system_clock::now() + std::chrono::seconds(settings.query_cache_ttl), settings.query_cache_compress_entries); - const size_t num_query_runs = query_cache->recordQueryRun(key); + const size_t num_query_runs = settings.query_cache_min_query_runs ? query_cache->recordQueryRun(key) : 1; /// try to avoid locking a mutex in recordQueryRun() if (num_query_runs <= settings.query_cache_min_query_runs) { LOG_TRACE(getLogger("QueryCache"),