Skip to main content

ClickHouse Internals Reference

Background on the ClickHouse system tables and concepts that TraceHouse relies on.

System Table Taxonomy

CategoryTableTypeActor
Instantaneous gaugessystem.metricsVirtualAll
Background-computed gaugessystem.asynchronous_metricsVirtualServer
Cumulative counterssystem.eventsVirtualAll
Time-series of gauges+counterssystem.metric_logMergeTreeAll
Time-series of async metricssystem.asynchronous_metric_logMergeTreeServer
Running queriessystem.processesVirtualUsers
Query historysystem.query_logMergeTreeUsers
Per-thread query detailssystem.query_thread_logMergeTreeUsers
MV executionsystem.query_views_logMergeTreeBackground
Running mergessystem.mergesVirtualBackground
Part lifecycle eventssystem.part_logMergeTreeBackground
Active mutationssystem.mutationsVirtualBackground
Replication statussystem.replicasVirtualBackground
Replication queuesystem.replication_queueVirtualBackground
Data partssystem.partsVirtualStorage
Column statisticssystem.columnsVirtualStorage
Disk volumessystem.disksVirtualServer
Tables metadatasystem.tablesVirtualStorage
Cluster topologysystem.clustersVirtualServer
Dictionariessystem.dictionariesVirtualStorage
Server text logssystem.text_logMergeTreeServer
Stack trace profilersystem.trace_logMergeTreeServer
OpenTelemetry spanssystem.opentelemetry_span_logMergeTreeAll
Crash recordssystem.crash_logMergeTreeServer

Virtual tables are computed from in-memory state - free to query. MergeTree tables (the *_log tables) are persisted and grow over time - they need TTL management.

Observability Tiers

Tier 1: Server-Wide Metrics

Global counters and gauges. Cheap to collect, always available. Tells you "how is the server doing" but not "who is responsible."

Tier 2: Per-Table Metrics

Part counts, sizes, merge activity per table. Available from virtual tables. Tells you "which tables are hot."

Tier 3: Per-Operation Metrics

Per-query ProfileEvents, per-merge CPU/IO from part_log. The most detailed level. Tells you "this specific query used X CPU."

ProfileEvents

ProfileEvents are ClickHouse's fine-grained counters attached to individual operations. Key categories:

  • Merge profiling - MergedRows, MergedUncompressedBytes, MergesTimeMilliseconds
  • Mutations - MutatedRows, MutatedUncompressedBytes
  • Insert pressure - InsertedRows, InsertedBytes, DelayedInserts
  • Replication - ReplicatedPartFetches, ReplicatedPartMerges
  • Query performance - SelectedRows, SelectedBytes, SelectedMarks
  • CPU/OS - OSCPUVirtualTimeMicroseconds, OSCPUWaitMicroseconds
  • Disk I/O - ReadBufferFromFileDescriptorReadBytes, WriteBufferFromFileDescriptorWriteBytes
  • Caches - MarkCacheHits, MarkCacheMisses, UncompressedCacheHits
  • Thread pools - GlobalThreadPoolSize, LocalThreadPoolSize