1. Home
  2. Knowledge Base
  3. ChistaDATA
  4. Removing Empty Parts In ClickHouse
  1. Home
  2. Knowledge Base
  3. ClickHouse
  4. Removing Empty Parts In ClickHouse
  1. Home
  2. Knowledge Base
  3. ClickHouse Performance
  4. Removing Empty Parts In ClickHouse

Removing Empty Parts In ClickHouse

The new feature of empty part removal was introduced in version 20.12. If TTL removes all rows from a part, older versions leave empty parts (with 0 rows) (see https://github.com/ClickHouse/ClickHouse/issues/5491). If you establish a TTL for your data, there are probably a lot of unused components in your system.

The updated version attempts to eliminate every space as soon as it is noticed. This one-time procedure is executed immediately following an upgrade. After that, TTL will automatically erase any empty portions.

When several replicas of the same table begin to delete empty spaces simultaneously, there is a problem. They can block one another due to the defect (https://github.com/ClickHouse/ClickHouse/issues/23292).

What we can do during an upgrade to prevent this issue:

  1. Drop empty partitions before upgrading to reduce the number of vacant portions in the system.
SELECT concat('alter table ',database, '.', table, ' drop partition id ''', partition_id, ''';')
FROM system.parts WHERE active
GROUP BY database, table, partition_id
HAVING count() = countIf(rows=0)

2. One copy (in a shard) will be upgraded/restarted at a time. There won’t be a deadlock due to replicas waiting for one another if just one replica cleans empty portions. Restart the first replica, then wait for the replication queue to complete before restarting the second.

Removing empty parts can be disabled by adding remove_empty_parts=0 to the default profile.

$ cat /etc/clickhouse-server/users.d/remove_empty_parts.xml
<clickhouse>
    <profiles>
        <default>
            <remove_empty_parts>0</remove_empty_parts>
        </default>
    </profiles>
</clickhouse>

 

Was this article helpful?

Related Articles

CHISTADATA IS COMMITTED TO OPEN SOURCE SOFTWARE AND BUILDING HIGH PERFORMANCE COLUMNSTORES

In the spirit of freedom, independence and innovation. ChistaDATA Corporation is not affiliated with ClickHouse Corporation 

Need Support?

Can't find the answer you're looking for?
Contact Support

ChistaDATA Inc. Knowledge base is licensed under the Apache License, Version 2.0 (the “License”)

Copyright 2022 ChistaDATA Inc

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.