Can someone explain me how TTL actually works

For TWCS I see this process like this:

  1. Within time window 1 we have data with some ttl (in SSTable1)
  2. Then within the time window N the ttl of data from SSTable1 has expired
  3. It creates a tombstone witch written in SSTableN ?

But how SSTable1 can be dropped, if SSTable1 and SSTableN can't be compacted cause they are from different time windows?

From docs: The primary motivation for TWCS is to separate data on disk by timestamp and to allow fully expired SSTables to drop more efficiently

From docs: Once the TTL has expired the data is converted to a tombstone which stays around for at least gc_grace_seconds


1 Answer 1


Yes, when data is written with a TTL then a tombstone with a future expiration date is inserted together with the data itself. This means that the data and the tombstone are written in the same time window so they will both be in the same SSTable.

Since the tombstone and the data are stored together, the TimeWindowCompactionStrategy "knows" that the all the data in an SSTable has expired and can simply drop it. Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.