ClickHouse/docs/en/operations/system-tables/mutations.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
4.2 KiB
Markdown
Raw Normal View History

2022-08-28 13:53:52 +00:00
---
2022-08-28 13:58:27 +00:00
slug: /en/operations/system-tables/mutations
2022-08-28 13:53:52 +00:00
---
2022-06-02 10:55:18 +00:00
# mutations
2022-11-16 02:32:44 +00:00
The table contains information about [mutations](/docs/en/sql-reference/statements/alter/index.md#mutations) of [MergeTree](/docs/en/engines/table-engines/mergetree-family/mergetree.md) tables and their progress. Each mutation command is represented by a single row.
## Columns:
2022-11-09 00:17:58 +00:00
- `database` ([String](/docs/en/sql-reference/data-types/string.md)) — The name of the database to which the mutation was applied.
2022-11-09 00:17:58 +00:00
- `table` ([String](/docs/en/sql-reference/data-types/string.md)) — The name of the table to which the mutation was applied.
2022-11-09 00:17:58 +00:00
- `mutation_id` ([String](/docs/en/sql-reference/data-types/string.md)) — The ID of the mutation. For replicated tables these IDs correspond to znode names in the `<table_path_in_clickhouse_keeper>/mutations/` directory in ClickHouse Keeper. For non-replicated tables the IDs correspond to file names in the data directory of the table.
2022-11-09 00:17:58 +00:00
- `command` ([String](/docs/en/sql-reference/data-types/string.md)) — The mutation command string (the part of the query after `ALTER TABLE [db.]table`).
2022-11-15 11:51:14 +00:00
- `create_time` ([DateTime](/docs/en/sql-reference/data-types/datetime.md)) — Date and time when the mutation command was submitted for execution.
2022-11-09 00:17:58 +00:00
- `block_numbers.partition_id` ([Array](/docs/en/sql-reference/data-types/array.md)([String](/docs/en/sql-reference/data-types/string.md))) — For mutations of replicated tables, the array contains the partitions' IDs (one record for each partition). For mutations of non-replicated tables the array is empty.
2022-11-09 00:17:58 +00:00
- `block_numbers.number` ([Array](/docs/en/sql-reference/data-types/array.md)([Int64](/docs/en/sql-reference/data-types/int-uint.md))) — For mutations of replicated tables, the array contains one record for each partition, with the block number that was acquired by the mutation. Only parts that contain blocks with numbers less than this number will be mutated in the partition.
2021-07-29 15:27:50 +00:00
In non-replicated tables, block numbers in all partitions form a single sequence. This means that for mutations of non-replicated tables, the column will contain one record with a single block number acquired by the mutation.
2022-11-09 00:17:58 +00:00
- `parts_to_do_names` ([Array](/docs/en/sql-reference/data-types/array.md)([String](/docs/en/sql-reference/data-types/string.md))) — An array of names of data parts that need to be mutated for the mutation to complete.
2022-11-09 00:17:58 +00:00
- `parts_to_do` ([Int64](/docs/en/sql-reference/data-types/int-uint.md)) — The number of data parts that need to be mutated for the mutation to complete.
2022-11-09 00:17:58 +00:00
- `is_done` ([UInt8](/docs/en/sql-reference/data-types/int-uint.md)) — The flag whether the mutation is done or not. Possible values:
- `1` if the mutation is completed,
2021-07-29 15:20:55 +00:00
- `0` if the mutation is still in process.
:::note
Even if `parts_to_do = 0` it is possible that a mutation of a replicated table is not completed yet because of a long-running `INSERT` query, that will create a new data part needed to be mutated.
:::
If there were problems with mutating some data parts, the following columns contain additional information:
2022-11-09 00:17:58 +00:00
- `latest_failed_part` ([String](/docs/en/sql-reference/data-types/string.md)) — The name of the most recent part that could not be mutated.
2022-11-15 11:51:14 +00:00
- `latest_fail_time` ([DateTime](/docs/en/sql-reference/data-types/datetime.md)) — The date and time of the most recent part mutation failure.
2022-11-09 00:17:58 +00:00
- `latest_fail_reason` ([String](/docs/en/sql-reference/data-types/string.md)) — The exception message that caused the most recent part mutation failure.
## Monitoring Mutations
To track the progress on the system.mutations table, use a query like the following - this requires read permissions on the system.* tables:
``` sql
SELECT * FROM clusterAllReplicas('cluster_name', 'db', system.mutations)
WHERE is_done=0 AND table='tmp';
```
:::tip
replace `tmp` in `table='tmp'` with the name of the table that you are checking mutations on.
:::
**See Also**
2022-11-16 02:32:44 +00:00
- [Mutations](/docs/en/sql-reference/statements/alter/index.md#mutations)
2022-11-09 00:17:58 +00:00
- [MergeTree](/docs/en/engines/table-engines/mergetree-family/mergetree.md) table engine
- [ReplicatedMergeTree](/docs/en/engines/table-engines/mergetree-family/replication.md) family