Database Reference
In-Depth Information
cqlsh:mastering_cassandra> SELECT ttl(expirable_col) FROM
demo_ttl WHERE id = 3;
ttl(expirable_col)
--------------------
null
(1 rows)
The following are a few things to be noted about expiring columns:
• The TTL is in seconds, so the smallest TTL can be 1 second
• You can change the TTL by updating the column (that is, read the column, update
the TTL, and insert the column)
• You can dismiss TTL by setting it to zero
• Although the client does not see the expired column, the space is kept occupied
until the compaction process after gc_grace_seconds is triggered; but note
that tombstones take a rather small space
Expiring cells can have some good uses; they remove the need for constantly watching
cron-like tasks that delete the data that has expired or is not required any more. For ex-
ample, an expiring shopping coupon or a user session can be stored with a TTL.
Note
Where is my super column?
People who have used Cassandra in version 1.1 or older must have heard of a super
column which is nothing but a cell that can have subcells. It was overly hyped and was
considered bad practice, the reason being, it was not automatically sorted like other cells.
You have to fetch all the subcolumns and it was adding unnecessary special casing in the
Cassandra code base. From Cassandra 1.2 onward, super columns were removed. The
Thrift request was still supported in 1.2, but it was internally using collections instead of
subcolumns.
As we will see, Cassandra 2.0 and later versions have much richer, better, and faster ways
to do all that you could do with super columns and more.
Search WWH ::




Custom Search