CQL for Cassandra 2.0

About expiring columns

Data in a column can have an optional expiration date called TTL (time to live). When a column is inserted, the client request can specify an optional TTL value, defined in seconds, for the data in the column. TTL columns are marked with a tombstone and after the requested amount of time has expired. Data is removed during the compaction process after gc_grace_seconds.

Use CQL to set the TTL for data in a column.

If you want to change the TTL of data, re-insert the column with a new TTL and values. In Cassandra, the insertion of a column and values is actually an insertion or update operation, depending on whether or not a previous version of the column exists. To update the TTL for data in a column, you have to read the column and then re-insert it with the new TTL value.

TTL data has a precision of one second, as calculated on the server. Therefore, a very small TTL probably does not make much sense. Moreover, the clocks on the servers should be synchronized; otherwise reduced precision could be observed because the expiration time is computed on the primary host that receives the initial insertion but is then interpreted by other hosts on the cluster.

A column that has expiring data has an additional overhead of 8 bytes in memory and on disk (to record the TTL and expiration time) compared to standard columns.