All Products
Search
Document Center

E-MapReduce:System tables

Last Updated:Mar 26, 2026

ClickHouse stores system tables in the system database. These tables are created automatically when the ClickHouse server starts, and most are held in random access memory (RAM). You can read from system tables and detach them from other tables, but you cannot drop or alter them.

This topic describes the six most commonly used system tables in E-MapReduce (EMR).

system.clusters

Stores information about the clusters defined in the configuration file and the servers in each cluster.

ColumnTypeDescription
clusterStringCluster name
shard_numUInt32Shard number within the cluster, starting from 1
shard_weightUInt32Relative weight of the shard when writing data
replica_numUInt32Replica number within the shard, starting from 1
host_nameStringHostname as specified in the configuration file
host_addressStringHost IP address resolved from the Domain Name System (DNS)
portUInt16Port used to connect to the host
userStringUsername used to connect to the host
errors_countUInt32Number of times the host failed to reach the replica
slowdowns_countUInt32Number of replica switches caused by slow connections during peer-to-peer requests
estimated_recovery_timeUInt32Seconds remaining until the replica error count resets to zero

Example: list all replicas in a cluster

SELECT * FROM system.clusters LIMIT 2 FORMAT Vertical;

Output:

Row 1:
──────
cluster:                 cluster_emr
shard_num:               1
shard_weight:            1
replica_num:             1
host_name:               emr-header-1.cluster-24****
host_address:            192.168.**.**
port:                    9000
is_local:                1
user:                    default
default_database:
errors_count:            0
estimated_recovery_time: 0

Row 2:
──────
cluster:                 cluster_emr
shard_num:               1
shard_weight:            1
replica_num:             2
host_name:               emr-worker-1.cluster-24****
host_address:            192.168.**.**
port:                    9000
is_local:                0
user:                    default
default_database:
errors_count:            0
estimated_recovery_time: 0

system.query_log

Stores metadata for executed queries, including start time, duration, error messages, and resource usage. It does not store query results.

Each query creates one or two rows depending on the outcome:

  • Successful query: two rows with type = QueryStart and QueryFinish

  • Error during execution: two rows with type = QueryStart and ExceptionWhileProcessing

  • Error before execution: one row with type = ExceptionBeforeStart

The table records two query categories:

  • Initial queries: sent directly by a client

  • Subqueries: initiated by another query for distributed execution; parent query details appear in the initial_* columns

ColumnTypeDescription
typeEnum8Query lifecycle event: QueryStart (1), QueryFinish (2), ExceptionBeforeStart (3), ExceptionWhileProcessing (4)
event_dateDateDate the event occurred
event_timeDateTimeTime the event occurred
event_time_microsecondsDateTime64Event time with microsecond precision
query_start_timeDateTimeTime query execution started
query_start_time_microsecondsDateTime64Query start time with microsecond precision
query_duration_msUInt64Query execution duration, in milliseconds
read_rowsUInt64Total rows read from all tables and table functions, including subqueries for IN and JOIN. For distributed queries, aggregates values from all replicas. Cache does not affect this value.
read_bytesUInt64Total bytes read from all tables and table functions, including subqueries for IN and JOIN. For distributed queries, aggregates values from all replicas. Cache does not affect this value.
written_rowsUInt64Rows written by INSERT queries; 0 for all other query types
written_bytesUInt64Bytes written by INSERT queries; 0 for all other query types
result_rowsUInt64Rows in the result of a SELECT or INSERT query
result_bytesUInt64RAM used to store the query result, in bytes
memory_usageUInt64Memory consumed by the query
queryStringQuery text
exceptionStringException message, if any
exception_codeInt32Exception code
stack_traceStringStack trace; empty if the query completed without error
is_initial_queryUInt81 if initiated by a client; 0 if initiated by another query for distributed execution
userStringUser who initiated the query
query_idStringQuery ID
addressIPv6Client IP address
portUInt16Client port number
initial_userStringUser who ran the initial query in a distributed execution
initial_query_idStringID of the initial query in a distributed execution
initial_addressIPv6IP address where the parent query originated
initial_portUInt16Port of the client that initiated the parent query
interfaceUInt8Interface used: 1 = TCP, 2 = HTTP
os_userStringOperating system username on the machine running clickhouse-client
client_hostnameStringHostname of the machine running clickhouse-client or another TCP client
client_nameStringName of clickhouse-client or another TCP client
client_revisionUInt32Revision of clickhouse-client or another TCP client
client_version_majorUInt32Major version of clickhouse-client or another TCP client
client_version_minorUInt32Minor version of clickhouse-client or another TCP client
client_version_patchUInt32Patch version of clickhouse-client or another TCP client
http_methodUInt8HTTP method: 0 = TCP interface, 1 = GET, 2 = POST
http_user_agentStringUserAgent HTTP header from HTTP queries
quota_keyStringQuota key from the quota configuration
revisionUInt32ClickHouse server revision
ProfileEventsMap(String, UInt64)Performance counters for various metrics. See the system.events table for descriptions.
SettingsMap(String, String)Settings changed when the client ran the query. Set log_query_settings = 1 to enable recording.
thread_idsArray(UInt64)IDs of threads that participated in query execution
Settings.NamesArray(String)Names of changed settings. Set log_query_settings = 1 to enable recording.
Settings.ValuesArray(String)Values corresponding to the names in Settings.Names

Example: find slow queries

SELECT
    query_id,
    query_duration_ms,
    read_rows,
    memory_usage,
    substring(query, 1, 100) AS query_preview
FROM system.query_log
WHERE type = 'QueryFinish'
ORDER BY query_duration_ms DESC
LIMIT 10
FORMAT Vertical;

Example: find failed queries

SELECT
    type,
    query_start_time,
    exception_code,
    exception,
    substring(query, 1, 100) AS query_preview
FROM system.query_log
WHERE type IN ('ExceptionBeforeStart', 'ExceptionWhileProcessing')
ORDER BY query_start_time DESC
LIMIT 10;

Example: check a single log entry

SELECT * FROM system.query_log LIMIT 1 FORMAT Vertical;

Output:

Row 1:
──────
type:                 QueryStart
event_date:           2021-08-12
event_time:           2021-08-12 14:11:58
query_start_time:     2021-08-12 14:11:58
query_duration_ms:    0
read_rows:            0
read_bytes:           0
written_rows:         0
written_bytes:        0
result_rows:          0
result_bytes:         0
memory_usage:         0
current_database:     default
query:                SELECT * FROM system.query_log LIMIT 1 FORMAT Vertical;
exception_code:       0
exception:
stack_trace:
is_initial_query:     1
user:                 default
query_id:             08e1336c-696f-4fad-b01b-255b77e56b1f
address:              ::ffff:127.0.0.1
port:                 60500
initial_user:         default
initial_query_id:     08e1336c-696f-4fad-b01b-255b77e56b1f
initial_address:      ::ffff:127.0.0.1
initial_port:         60500
interface:            1
os_user:              root
client_hostname:      emr-header-1.cluster-235053
client_name:          ClickHouse
client_revision:      54438
client_version_major: 20
client_version_minor: 8
client_version_patch: 12
http_method:          0
http_user_agent:
quota_key:
revision:             54438
thread_ids:           []
ProfileEvents.Names:  []
ProfileEvents.Values: []
Settings.Names:       ['use_uncompressed_cache','load_balancing','max_memory_usage']
Settings.Values:      ['0','random','10000000000']

system.zookeeper

Stores information about nodes in ZooKeeper. This table exists only when ZooKeeper is configured.

Every query against system.zookeeper must include a WHERE clause with either a path = or path IN condition, corresponding to the ZooKeeper path whose child nodes you want to retrieve. If the specified path does not exist, an exception is thrown.

ColumnTypeDescription
nameStringNode name
pathStringPath to the node
valueStringNode value
dataLengthInt32Length of the node value
numChildrenInt32Number of child nodes
czxidInt64Transaction ID that created the node
mzxidInt64Transaction ID of the last modification
pzxidInt64Transaction ID of the last change to child nodes (addition or deletion)
ctimeDateTimeTime the node was created
mtimeDateTimeTime the node was last modified
versionInt32Node version; increments with each change
cversionInt32Transaction ID of the last deletion or addition of child nodes
aversionInt32Number of changes to the access control list (ACL)
ephemeralOwnerInt64Transaction ID of the owner of this ephemeral node

Example queries

Retrieve all child nodes under a specific path:

SELECT *
FROM system.zookeeper
WHERE path = '/clickhouse/tables/01-08/visits/replicas'
FORMAT Vertical;

Retrieve child nodes under multiple paths in a single query:

SELECT *
FROM system.zookeeper
WHERE path IN ('/', '/clickhouse');

Output for the first query:

Row 1:
──────
name:           example01-08-1.yandex.ru
value:
czxid:          932998691229
mzxid:          932998691229
ctime:          2015-03-27 16:49:51
mtime:          2015-03-27 16:49:51
version:        0
cversion:       47
aversion:       0
ephemeralOwner: 0
dataLength:     0
numChildren:    7
pzxid:          987021031383
path:           /clickhouse/tables/01-08/visits/replicas

Row 2:
──────
name:           example01-08-2.yandex.ru
value:
czxid:          933002738135
mzxid:          933002738135
ctime:          2015-03-27 16:57:01
mtime:          2015-03-27 16:57:01
version:        0
cversion:       37
aversion:       0
ephemeralOwner: 0
dataLength:     0
numChildren:    7
pzxid:          987021252247
path:           /clickhouse/tables/01-08/visits/replicas

system.replicas

Stores status information for all replicated tables on the local server. Use this table to monitor replica health.

Only one replica can hold the leader role at a time. The leader schedules background merge operations. Write operations can run on any replica that is available and has an active ZooKeeper session, regardless of whether it is the leader.

A replica enters read-only mode in any of these situations:

  • The configuration has no ZooKeeper session defined

  • An unknown error occurs when reinitializing a ZooKeeper session

  • ZooKeeper is reinitialized mid-session

ColumnTypeDescription
databaseStringDatabase name
tableStringTable name
engineStringTable engine name
is_leaderUInt81 if this replica is currently the leader
can_become_leaderUInt81 if this replica is eligible to become the leader
is_readonlyUInt81 if this replica is in read-only mode
is_session_expiredUInt81 if the ZooKeeper session has expired; similar behavior to is_readonly
future_partsUInt32Number of data parts expected from pending inserts or merges
parts_to_checkUInt32Number of data parts queued for integrity verification
zookeeper_pathStringZooKeeper path for the table data
replica_nameStringName of this replica in ZooKeeper; unique across replicas of the same table
replica_pathStringZooKeeper path for replica data; equivalent to zookeeper_path/replicas/replica_path
columns_versionInt32Table schema version; counts the number of ALTER operations applied. Replicas with different values have not all applied the same ALTER operations.
queue_sizeUInt32Number of pending operations (inserts and merges); same value as future_parts
inserts_in_queueUInt32Number of data blocks waiting to be inserted. A large value may indicate a problem.
merges_in_queueUInt32Number of data blocks waiting to be merged. Merges can take time, so this may stay above zero for extended periods.
part_mutations_in_queueUInt32Number of pending mutations
queue_oldest_timeDateTimeTimestamp of the oldest queued operation, if queue_size > 0
inserts_oldest_timeDateTimeTimestamp of the oldest queued insert
merges_oldest_timeDateTimeTimestamp of the oldest queued merge
part_mutations_oldest_timeDateTimeTimestamp of the oldest queued mutation
log_max_indexUInt64Highest entry number in the general activity log. Non-zero only when an active ZooKeeper session exists.
log_pointerUInt64Highest log entry number the replica has copied to its execution queue, plus one. If log_pointer < log_max_index, the replica is behind. Non-zero only when an active ZooKeeper session exists.
last_queue_updateDateTimeTime the queue was last updated. Non-zero only when an active ZooKeeper session exists.
absolute_delayUInt64Current replication lag for this replica, in seconds. Non-zero only when an active ZooKeeper session exists.
total_replicasUInt8Total number of known replicas for the table
active_replicasUInt8Number of replicas with an active ZooKeeper session

Example: check replica status for a table

SELECT * FROM system.replicas WHERE table = 'visits' FORMAT Vertical;

Example: identify lagging replicas

SELECT
    database,
    table,
    replica_name,
    absolute_delay,
    queue_size,
    inserts_in_queue,
    merges_in_queue
FROM system.replicas
WHERE absolute_delay > 0
ORDER BY absolute_delay DESC;

Output for the first query:

Row 1:
──────
database:                   cltest
table:                      flat_xl_customer_local
engine:                     ReplicatedMergeTree
is_leader:                  1
can_become_leader:          1
is_readonly:                0
is_session_expired:         0
future_parts:               0
parts_to_check:             0
zookeeper_path:             /cltest/cluster_emr-1/flat_xl_customer_local
replica_name:               emr-header-1.cluster-235053
replica_path:               /cltest/cluster_emr-1/flat_xl_customer_local/replicas/emr-header-1.cluster-235053
columns_version:            -1
queue_size:                 0
inserts_in_queue:           0
merges_in_queue:            0
part_mutations_in_queue:    0
queue_oldest_time:          1970-01-01 08:00:00
inserts_oldest_time:        1970-01-01 08:00:00
merges_oldest_time:         1970-01-01 08:00:00
part_mutations_oldest_time: 1970-01-01 08:00:00
oldest_part_to_get:
oldest_part_to_merge_to:
oldest_part_to_mutate_to:
log_max_index:              100157
log_pointer:                100158
last_queue_update:          1970-01-01 08:00:00
absolute_delay:             0
total_replicas:             2
active_replicas:            2
zookeeper_exception:

system.storage_policies

Stores the storage policies and volume priorities defined in the server configuration file.

ColumnTypeDescription
policy_nameStringStorage policy name
volume_nameStringVolume name within the storage policy
volume_priorityUInt64Volume order in the configuration file
disksStringNames of disks assigned to this volume
max_data_part_sizeUInt64Maximum size of a data part that can be stored on this volume's disks
move_factorFloat64Ratio of free disk space to total disk space. If the ratio exceeds this value, ClickHouse moves data to the next volume.

Example: list all storage policies

SELECT * FROM system.storage_policies;

Output:

┌policy_name─┬─volume_name─┬─volume_priority─┬─disks────────────┬─volume_type─┬─max_data_part_size┬─move_factor─┐
│ default      │ default     │               1 │ ['default']                       │ JBOD        │                  0 │           0 │
│ hdd_in_order │ single      │               1 │ ['disk1','disk2','disk3','disk4'] │ JBOD        │                  0 │         0.1 │
└───────┴──────┴─────────┴─────────────────┴───────┴─────────┴─────────┘

system.disks

Stores information about the disks defined in the server configuration file.

ColumnTypeDescription
nameStringDisk name as defined in the configuration file
pathStringMount path of the disk in the file system
free_spaceUInt64Available disk space, in bytes
total_spaceUInt64Total disk capacity, in bytes
keep_free_spaceUInt64Disk space reserved and kept free, in bytes. Set by the keep_free_space_bytes parameter in the disk configuration.

Example: check disk space across all configured disks

SELECT
    name,
    path,
    formatReadableSize(free_space) AS free,
    formatReadableSize(total_space) AS total,
    round(free_space / total_space * 100, 1) AS free_pct
FROM system.disks;

Example: list raw disk information

SELECT * FROM system.disks;

Output:

┌─name─┬─path─────────┬──free_space┬─total_space┬─keep_free_space┬─type──┐
│ default │ /var/lib/clickhouse/   │ 17236594688 │ 84014424064 │               0 │ local │
│ disk1   │ /mnt/disk1/clickhouse/ │ 17226108928 │ 84003938304 │        10485760 │ local │
│ disk2   │ /mnt/disk2/clickhouse/ │ 28623364096 │ 84003938304 │        10485760 │ local │
│ disk3   │ /mnt/disk3/clickhouse/ │ 34770505728 │ 84003938304 │        10485760 │ local │
│ disk4   │ /mnt/disk4/clickhouse/ │ 59107045376 │ 84003938304 │        10485760 │ local │
└────┴─────────────┴───────┴──────┴────────┴─────┘