Backups are an exception: Cloud storage lifecycle policies are a valid strategy for Backup Lifecycle management. See Backup Strategy for more details.
Do Not Use Cloud Object Lifecycle Policies
ClickHouse stores data in object storage (S3, GCS, or S3-compatible backends) and manages the lifecycle of those objects internally. Cloud-provider lifecycle policies — such as S3 Lifecycle, GCS Object Lifecycle Management, or equivalent services on other providers — operate independently of ClickHouse and will delete or transition objects that ClickHouse still depends on. Specifically, do not configure:- S3 Lifecycle rules (expiration, transition, abort incomplete multipart uploads with short timeouts)
- GCS Object Lifecycle Management (delete, SetStorageClass)
- Intelligent-Tiering or automatic storage class transitions
TTL (Time-to-Live) Rules
TTL rules let you define automatic data expiration at the table level. When data meets the TTL condition, ClickHouse removes it during background merges.Delete Data After a Fixed Period
Add a TTL clause to your table definition to automatically delete rows older than a specified interval:Conditional TTL
You can apply different retention periods based on data content:Add TTL to an Existing Table
Best Practices for TTL
- Align partitions with TTL granularity. If TTL is in months, partition by month (
toYYYYMM). If TTL is in days, partition by day (toYYYYMMDD). This allows ClickHouse to drop whole partitions instead of rewriting data parts. - Use
DELETE(the default action) to remove expired rows. Other actions likeTO VOLUMEorTO DISKmove data between storage tiers but do not free space. - Monitor TTL execution with the
system.partstable. Check that parts with expired data are being merged and removed.