Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

vigneshmaheshssn_140152 avatar image
vigneshmaheshssn_140152 asked ·

Does changing the default TTL on a table update existing records?

if we alter table with new TTL value , if the TTL value of the existing records in that table will also get changed or the new TTL value will be applicable only for new records coming into the table post table alter

schema
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

Changing the default TTL does not update the expiration on existing data.

Cassandra SSTables are immutable -- they do not change once they've been written to disk. If you change the default TTL, you will need to update the existing data to reflect the change.

You need to write an app (for example in Spark) that would read each partition, recalculate the TTL on it then save it. There isn't a ready-made solution for this so you'll have to develop one yourself. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.