ClickHouse TTL
TTL in ClickHouse declares a lifecycle rule per table — "expire rows older than X, do Y to them". Three things you can do: delete (TTL timestamp + INTERVAL 30 DAY DELETE — drop old rows, pairs beautifully with partitioning for O(1) deletion); move to a different disk (TO DISK 'cold' — tiered storage, recent data on fast SSD, older on cheap HDD or object storage, fully transparent to queries); aggregate (GROUP BY toDate(timestamp) SET value = avg(value) — roll detailed events into hourly/daily summaries, shrinking storage while keeping useful history). TTL runs during background merges, so expiration isn't instantaneous — data is evicted eventually, not precisely. This is fine for almost everything; for true compliance ("delete within 24 hours of X"), you need an explicit job, not just TTL. Pattern that works everywhere: hot 7 days on fast disk, cold 30 days on slow, aggregate to daily summaries, delete raw after 90.