max_concurrent_queries system table query counting variance
0 reputation · 14 Aug 2026, 11:52 UTC
0 reputation · 14 Aug 2026, 11:52 UTC
The max_concurrent_queries setting governs the maximum number of simultaneously executing queries per user in ClickHouse, rejecting excess requests with a Too many concurrent queries exception rather than queuing them. A documented ambiguity exists regarding whether system table queries—such as those targeting system.query_log or SHOW QUERIES—are included in this per-user counter, as behavior may vary across ClickHouse builds and server configurations. This uncertainty affects predictable concurrency budgeting, especially in workloads that interleave user queries with diagnostic or monitoring queries.
Does the max_concurrent_queries limit uniformly account for system table query execution across all supported ClickHouse versions, or does inclusion depend on build-specific query log implementation? Furthermore, how does the presence of system-initiated queries affect the effective concurrency boundary for active user queries, and is there a consistent method to verify which query categories increment the counter?
37275 reputation · 14 Aug 2026, 19:19 UTC
The max_concurrent_queries limit applies uniformly to queries executed under the same authenticated user context. Whether a SELECT against system.query_log, system.processes, or SHOW PROCESSLIST counts toward this limit depends solely on whether it runs under the user whose limit is configured—not on the query's target table. System-initiated operations (e.g., background merges, mutation processing) typically execute in internal contexts and do not consume the user's concurrent query slots.
max_concurrent_queries is a per-user setting enforced when a query enters the execution queue.Too many concurrent queries.clickhouse-client with the same credentials) follow the same path as user queries and will be rejected if the limit is reached.SELECT version(), currentUser() to confirm the build and user.max_concurrent_queries=2 for your user, then execute two long-running queries (e.g., SELECT sleep(30)) concurrently.SELECT count() FROM system.query_log WHERE event_time > now() - 60. If you receive Too many concurrent queries, the system query counted.SELECT user, count() FROM system.processes WHERE is_initial_query GROUP BY user to observe active slots (exclude the probe query by filtering query NOT LIKE '%system.query_log%' or using connection_id).Are you running monitoring queries (e.g., from clickhouse-client, Grafana, or application code) under the same user account as your application queries? If monitoring uses a separate user or role, system queries won't reduce your application's available concurrent slots.
Use comments to ask for clarification. Post a solution as an answer.
37,275 reputation · 14 Aug 2026, 20:10 UTC
When a user runs a distributed query against system.query_log or any cluster table, the initiator node consumes one slot under that user's max_concurrent_queries, but each remote shard enforces its own per-user limit independently. A query that passes locally can still be rejected remotely with Too many concurrent queries if a shard is saturated.
For cluster-wide protection, max_concurrent_queries_for_all_users provides a global ceiling that also includes user-initiated system-table queries. Verify the effective value with SHOW SETTINGS LIKE 'max_concurrent_queries' in the same session, since settings profiles can override the per-user limit.