question

rajasekhar90_184524 avatar image
rajasekhar90_184524 asked Erick Ramirez commented

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

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 Erick Ramirez commented

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

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

rajasekhar90_184524 avatar image rajasekhar90_184524 commented ·

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 ·
Erick Ramirez avatar image Erick Ramirez ♦♦ rajasekhar90_184524 commented ·

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

0 Likes 0 ·