Company
Date Published
Author
Denys Golotiuk
Word count
2926
Language
English
Hacker News points
None

Summary

ClickHouse, the world's fastest database for real-time analytics, offers multiple ways to efficiently update and delete data in analytical environments, depending on the specific use case. Lightweight Deletes via the DELETE FROM syntax are the most efficient way to remove data from ClickHouse, but may not provide immediate disk space savings if deleted data "exists" on disk. Mutation-based deletes via ALTER...DELETE can be used when immediate disk space savings are required, such as for compliance purposes. Updates and deletes can also be performed using ALTER...UPDATE and ALTER...DELETE mutations, respectively, which are asynchronous by default but can be made synchronous with the mutations_sync parameter set to 1 or 2. Other methods include using TTLs (time-to-live) for regular data removal, CollapsingMergeTree for frequent updates or removal of individual rows, ReplacingMergeTree for upsert operations based on versioning, and dropping partitions when removing large blocks of data regularly. Additionally, creating new columns and dropping old ones can be a more efficient way to update entire tables.