SYSTEM Statements

## SYSTEM CLEAR|DROP COMPILED EXPRESSION CACHE[​](#drop-compiled-expression-cache "Direct link to SYSTEM CLEAR|DROP COMPILED EXPRESSION CACHE")

Clears the compiled expression cache.
The compiled expression cache is enabled/disabled with the query/user/profile-level setting [`compile_expressions`](/docs/operations/settings/settings#compile_expressions).

## SYSTEM CLEAR|DROP QUERY CONDITION CACHE[​](#drop-query-condition-cache "Direct link to SYSTEM CLEAR|DROP QUERY CONDITION CACHE")

Clears the query condition cache.

## SYSTEM CLEAR|DROP QUERY CACHE[​](#drop-query-cache "Direct link to SYSTEM CLEAR|DROP QUERY CACHE")

```
SYSTEM CLEAR QUERY CACHE;
SYSTEM CLEAR QUERY CACHE TAG '<tag>'
```

Clears the [query cache](/docs/operations/query-cache).
If a tag is specified, only query cache entries with the specified tag are deleted.

## SYSTEM CLEAR|DROP FORMAT SCHEMA CACHE[​](#system-drop-schema-format "Direct link to SYSTEM CLEAR|DROP FORMAT SCHEMA CACHE")

Clears cache for schemas loaded from [`format_schema_path`](/docs/operations/server-configuration-parameters/settings#format_schema_path).

Supported targets:

- Protobuf: Removes imported Protobuf message definitions from memory.
- Files: Deletes cached schema files stored locally in the [`format_schema_path`](/docs/operations/server-configuration-parameters/settings#format_schema_path), generated when `format_schema_source` is set to `query`.
  Note: If no target is specified, both caches are cleared.

```
SYSTEM CLEAR|DROP FORMAT SCHEMA CACHE [FOR Protobuf/Files]
```

## SYSTEM FLUSH LOGS[​](#flush-logs "Direct link to SYSTEM FLUSH LOGS")

Flushes buffered log messages to system tables, e.g. system.query\_log. Mainly useful for debugging since most system tables have a default flush interval of 7.5 seconds.
This will also create system tables even if message queue is empty.

```
SYSTEM FLUSH LOGS [ON CLUSTER cluster_name] [log_name|[database.table]] [, ...]
```

If you don't want to flush everything, you can flush one or more individual logs by passing either their name or their target table:

```
SYSTEM FLUSH LOGS query_log, system.query_views_log;
```

## SYSTEM RELOAD CONFIG[​](#reload-config "Direct link to SYSTEM RELOAD CONFIG")

Reloads ClickHouse configuration. Used when configuration is stored in ZooKeeper. Note that `SYSTEM RELOAD CONFIG` does not reload `USER` configuration stored in ZooKeeper, it only reloads `USER` configuration that is stored in `users.xml`. To reload all `USER` config use `SYSTEM RELOAD USERS`

```
SYSTEM RELOAD CONFIG [ON CLUSTER cluster_name]
```

## SYSTEM RELOAD USERS[​](#reload-users "Direct link to SYSTEM RELOAD USERS")

Reloads all access storages, including: users.xml, local disk access storage, replicated (in ZooKeeper) access storage.

```
SYSTEM RELOAD USERS [ON CLUSTER cluster_name]
```

## SYSTEM SHUTDOWN[​](#shutdown "Direct link to SYSTEM SHUTDOWN")

Not supported in ClickHouse Cloud

Normally shuts down ClickHouse (like `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`)

## SYSTEM KILL[​](#kill "Direct link to SYSTEM KILL")

Aborts ClickHouse process (like `kill -9 {$ pid_clickhouse-server}`)

## SYSTEM INSTRUMENT[​](#instrument "Direct link to SYSTEM INSTRUMENT")

Manages instrumentation points using LLVM's XRay feature which is available when ClickHouse is built using `ENABLE_XRAY=1`.
This enables to debug and profile in production without modifying the source code and with minimal overhead.
When no instrumentation point is added, the performance penalty is negligible because it only adds an extra jump to a nearby
address at the prolog and epilog of those functions that are longer than 200 instructions.

### SYSTEM INSTRUMENT ADD[​](#instrument-add "Direct link to SYSTEM INSTRUMENT ADD")

Adds a new instrumentation point. Functions instrumented can be inspected in the [`system.instrumentation`](/docs/operations/system-tables/instrumentation) system table. More than one handler can be added for the same function, and they will be executed in the same order the instrumentation is added.
The functions to be instrumented can be collected from [`system.symbols`](/docs/operations/system-tables/symbols) system table.

There are three different kind of handlers to add to functions:

**Syntax**

```
SYSTEM INSTRUMENT ADD FUNCTION HANDLER [PARAMETERS]
```

where `FUNCTION` is any function or substring of a function such as `QueryMetricLog::startQuery`, and the handler one of the following

#### LOG[​](#instrument-add-log "Direct link to LOG")

Prints the text provided as an argument and the stack trace either on `ENTRY` or `EXIT` of the function.

```
SYSTEM INSTRUMENT ADD 'QueryMetricLog::startQuery' LOG ENTRY 'this is a log printed at entry'
SYSTEM INSTRUMENT ADD 'QueryMetricLog::startQuery' LOG EXIT 'this is a log printed at exit'
```

#### SLEEP[​](#instrument-add-sleep "Direct link to SLEEP")

Sleeps for a number of fix amount of seconds either on `ENTRY` or `EXIT`:

```
SYSTEM INSTRUMENT ADD 'QueryMetricLog::startQuery' SLEEP ENTRY 0.5
```

or for a uniformly distributed random amount of seconds providing min and max separated by a whitespace:

```
SYSTEM INSTRUMENT ADD 'QueryMetricLog::startQuery' SLEEP ENTRY 0 1
```

#### PROFILE[​](#instrument-add-profile "Direct link to PROFILE")

Measures the time spent between `ENTRY` and `EXIT` of a function.
The result of the profiling is stored in [`system.trace_log`](/docs/operations/system-tables/trace_log) and can be converted
to [Chrome Event Trace Format](/docs/operations/system-tables/trace_log#chrome-event-trace-format).

```
SYSTEM INSTRUMENT ADD 'QueryMetricLog::startQuery' PROFILE
```

### SYSTEM INSTRUMENT REMOVE[​](#instrument-remove "Direct link to SYSTEM INSTRUMENT REMOVE")

Removes either a single instrumentation point with:

```
SYSTEM INSTRUMENT REMOVE ID
```

all of them using the `ALL` parameter:

```
SYSTEM INSTRUMENT REMOVE ALL
```

a set of IDs from a subquery:

```
SYSTEM INSTRUMENT REMOVE (SELECT id FROM system.instrumentation WHERE handler = 'log')
```

or all instrumentation points that match a given function\_name:

```
SYSTEM INSTRUMENT REMOVE 'QueryMetricLog::startQuery'
```

The instrumentation point information can be collected from [`system.instrumentation`](/docs/operations/system-tables/instrumentation) system table.

## Managing Distributed Tables[​](#managing-distributed-tables "Direct link to Managing Distributed Tables")

ClickHouse can manage [distributed](/docs/engines/table-engines/special/distributed) tables. When a user inserts data into these tables, ClickHouse first creates a queue of the data that should be sent to cluster nodes, then asynchronously sends it. You can manage queue processing with the [`STOP DISTRIBUTED SENDS`](#stop-distributed-sends), [FLUSH DISTRIBUTED](#flush-distributed), and [`START DISTRIBUTED SENDS`](#start-distributed-sends) queries. You can also synchronously insert distributed data with the [`distributed_foreground_insert`](/docs/operations/settings/settings#distributed_foreground_insert) setting.

### SYSTEM STOP DISTRIBUTED SENDS[​](#stop-distributed-sends "Direct link to SYSTEM STOP DISTRIBUTED SENDS")

Disables background data distribution when inserting data into distributed tables.

```
SYSTEM STOP DISTRIBUTED SENDS [db.]<distributed_table_name> [ON CLUSTER cluster_name]
```

Note

In case of [`prefer_localhost_replica`](/docs/operations/settings/settings#prefer_localhost_replica) is enabled (the default), the data to local shard will be inserted anyway.

### SYSTEM FLUSH DISTRIBUTED[​](#flush-distributed "Direct link to SYSTEM FLUSH DISTRIBUTED")

Forces ClickHouse to send data to cluster nodes synchronously. If any nodes are unavailable, ClickHouse throws an exception and stops query execution. You can retry the query until it succeeds, which will happen when all nodes are back online.

You can also override some settings via `SETTINGS` clause, this can be useful to avoid some temporary limitations, like `max_concurrent_queries_for_all_users` or `max_memory_usage`.

```
SYSTEM FLUSH DISTRIBUTED [db.]<distributed_table_name> [ON CLUSTER cluster_name] [SETTINGS ...]
```

Note