Merge pull request #60348 from zhongyuankai/query_cache_minor_change

QueryCache: Don't acquire the query count mutex if not necessary
This commit is contained in:
Robert Schulze 2024-03-01 11:17:49 +01:00 committed by GitHub
commit 4171ede556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1167,7 +1167,7 @@ static std::tuple<ASTPtr, BlockIO> 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"),