mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-13 19:14:30 +00:00
649386ff0f
Поправил английскую версию и перевел на русский язык.
1.7 KiB
1.7 KiB
toc_priority | toc_title |
---|---|
47 | OPTIMIZE |
OPTIMIZE Statement
OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE]
This query tries to initialize an unscheduled merge of data parts for tables with a table engine from the MergeTree family.
The OPTMIZE
query is also supported for the MaterializedView and the Buffer engines. Other table engines aren’t supported.
When OPTIMIZE
is used with the ReplicatedMergeTree family of table engines, ClickHouse creates a task for merging and waits for execution on all nodes (if the replication_alter_partitions_sync
setting is enabled).
- If
OPTIMIZE
doesn’t perform a merge for any reason, it doesn’t notify the client. To enable notifications, use the optimize_throw_if_noop setting. - If you specify a
PARTITION
, only the specified partition is optimized. How to set partition expression. - If you specify
FINAL
, optimization is performed even when all the data is already in one part. Also merge is forced even if concurrent merges are performed. - If you specify
DEDUPLICATE
, then completely identical rows will be deduplicated (all columns are compared), it makes sense only for the MergeTree engine.
!!! warning "Warning"
OPTIMIZE
can’t fix the “Too many parts” error.