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

rajasekhar90_184524 avatar image
rajasekhar90_184524 asked ·

How do I update the TTL for all the old data in a table?

We have a table that doesn't have TTL set till now. We are planning to alter the table and set TTL with 28 days. Could you please let me know how we can update and set the TTL for the existing data?

ttl
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 ·

There is no out-of-the-box solution to update the TTL of all the partitions in the table.

You will need to write a custom application to iterate over all the partitions and update them one-by-one. We recommend using Spark for this type of operation since this job will require a full table scan. Spark via the Spark-Cassandra-connector will efficiently execute this job. Cheers!

2 comments 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.

Thanks Erick!

One more follow-up question - What would be the best approach in case if want to delete the old data after changing the Table TTL?

0 Likes 0 ·

It's exactly the same -- you have to write an app for it. Cheers!

0 Likes 0 ·