Expiring data with time-to-live

Columns and tables support an optional expiration period called TTL (time-to-live).

You define the TTL value in seconds. The data expires once it exceeds the TTL period, and it is then marked with a tombstone.

During the grace period (gc_grace_seconds), expired data is still stored as tombstoned data in the database. Tombstoned data is scanned by database read operations, but it isn’t included in the returned data.

Normal compaction and repair processes automatically remove the tombstone data.

TTL requirements and limitations

  • TTL is not supported on counter columns.

  • TTL precision is one second, which is calculated by the coordinator node. When setting a TTL, ensure that all nodes in the cluster have synchronized clocks.

  • A very short TTL is not useful.

  • Expiring data uses additional 8 bytes of memory and disk space to record the TTL and grace period.

The database storage engine can only encode TTL timestamps through January 19 2038 03:14:07 UTC due to the Year 2038 problem.

The TTL date overflow policy (-Dcassandra.expiration_date_overflow_policy) determines whether requests with expiration timestamps later than the maximum date are rejected or inserted.

Set a TTL for a specific column

The USING TTL clause can be used to set the TTL when you insert or update data. For more information and examples, see Set the time-to-live (TTL).

To change the TTL of a specific column, you must re-insert the data with a new TTL. The column is upserted with the new TTL.

To remove the TTL from a column, set the TTL to zero. For details, see UPDATE.

Set a TTL for a table

Use CREATE TABLE or ALTER TABLE to define the default_time_to_live property for all columns in a table.

If any column exceeds the TTL, then the entire row is deleted.

Setting TTL on a column using the INSERT or UPDATE command overrides the table-level TTL.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax, an IBM Company | Privacy policy | Terms of use | Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com