Search code examples
sqldatabasereplicationddlclickhouse

Clickhouse. Optimize table on cluster doesnt work properly


I have a cluster 2x2 v19.15.2.2 with replicated partitioned table.

select * from system.parts 

=> some_part_0_0_1, some_part_0_0_2 and etc.

shows me some unmerged parts.

Doc says, that during call optimize all the parts will be merged, but after call such query

// current settings on each node 
optimize_throw_if_noop = 1 
replication_alter_partitions_sync = 2 

optimize table my_table on cluster my_cluster partition my_partition final

It just generate one more part and old parts doesnt merge.

What i am doing wrong ? Thanks


Solution

  • select * from system.parts WHERE active

    merge process (initiated by optimize) merges several old (active) parts into a new active part. Old parts (merged) became inactive and will be removed after 8 minutes (defending 8 minutes because CH does not use fsync by performance reason).