---
title: "Essential Monitoring Queries - part 2 - SELECT Queries"
description: "A set of SQL queries against ClickHouse system tables (system.parts, system.query_log, system.processes, system.stack_trace) for monitoring and troubleshooting SELECT workloads: cluster size overview, most expensive queries, ProfileEvents diffs between two query versions, hourly duration trends, per-client query counts, and diagnosing TOO_MANY_SIMULTANEOUS_QUERIES."
url: "https://swe.quest/articles/essential-monitoring-queries-part-2-select-queries-f0cc886a137efe02"
canonical: "https://clickhouse.com/blog/monitoring-troubleshooting-select-queries-clickhouse"
source: "ClickHouse"
published: "2023-01-03"
difficulty: "medium"
kind: "How-to"
reading_minutes: 10
tags: ["analytics","observability","performance","sql"]
---

# Essential Monitoring Queries - part 2 - SELECT Queries

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2023-01-03, 10 min read, How-to. Original: [https://clickhouse.com/blog/monitoring-troubleshooting-select-queries-clickhouse](https://clickhouse.com/blog/monitoring-troubleshooting-select-queries-clickhouse)

## Summary

A set of SQL queries against ClickHouse system tables (system.parts, system.query\_log, system.processes, system.stack\_trace) for monitoring and troubleshooting SELECT workloads: cluster size overview, most expensive queries, ProfileEvents diffs between two query versions, hourly duration trends, per-client query counts, and diagnosing TOO\_MANY\_SIMULTANEOUS\_QUERIES. Setting send\_logs\_level = 'trace' in clickhouse-client exposes per-query execution logs; in the UK price paid example, adding a projection ordered by town and price cut marks read from 3401 to 266 and latency from 1.2s to 0.028s. Queries use clusterAllReplicas for ClickHouse Cloud and can be adapted for self-managed clusters.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [SQL](https://swe.quest/tags/sql.md) (Languages)

## Prerequisites

- ClickHouse basics ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))
- SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

ClickHouse, ClickHouse Cloud, system.query\_log, clickhouse-client, projections, ProfileEvents

## Related posts

- [System Tables and a Window into the Internals of ClickHouse](https://swe.quest/articles/system-tables-and-a-window-into-the-internals-of-clickhouse-4ad666c7ab1a3be7.md): ClickHouse · 2022-12-21 · Medium · 13 min read · Analytics & OLAP, Observability, Debugging, SQL
  ClickHouse system tables are read-only virtual tables in the system database that expose server state, settings, metrics, errors, parts and query history.
- [Common issues you can solve using advanced monitoring dashboards](https://swe.quest/articles/common-issues-you-can-solve-using-advanced-monitoring-dashboards-6105f55cb7f566d8.md): ClickHouse · 2024-12-30 · Medium · 9 min read · Observability, Analytics & OLAP, Databases, Performance engineering
  ClickHouse ships a built-in Advanced Dashboard at /dashboard that charts query, MergeTree, OS and S3/cache metrics.
- [Essential Monitoring Queries - part 1 - INSERT Queries](https://swe.quest/articles/essential-monitoring-queries-part-1-insert-queries-eda633e3819dfbe1.md): ClickHouse · 2022-12-28 · Medium · 10 min read · Analytics & OLAP, Observability, SQL
  ClickHouse system tables such as part\_log, query\_log, asynchronous\_insert\_log, asynchronous\_metric\_log and parts can be queried with SQL to monitor and troubleshoot INSERT workloads.
- [Monitor SLAs and scale ClickHouse Cloud with clickhousectl and agents](https://swe.quest/articles/monitor-slas-and-scale-clickhouse-cloud-with-clickhousectl-and-agents-941d1a23a934edc8.md): ClickHouse · 2026-06-05 · Medium · 7 min read · Analytics & OLAP, SRE, Capacity planning, AI agents, Observability
  Tagging frontend queries with \`log\_comment\` lets you compute a specific latency SLA, such as p99 under 200 ms, directly from \`system.query\_log\` across replicas.
- [A simple guide to ClickHouse query optimization: part 1](https://swe.quest/articles/a-simple-guide-to-clickhouse-query-optimization-part-1-007f8d8516577455.md): ClickHouse · 2024-12-11 · Medium · 20 min read · Analytics & OLAP, Performance engineering, SQL, Query engines
  Slow ClickHouse queries can be diagnosed with system.query\_log (duration, rows read, memory, CPU, cache metrics) and the EXPLAIN statement, illustrated on the NYC Taxi dataset in the ClickHouse Playground.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
