4

Suppose I inserted a column at second-1 and another column at second-2. Default TTL for table is set to 10 seconds for example:

Question 1: Is data1 and data2 going to be deleted after 10 seconds or data 1 will be deleted after 10 seconds and data-2 after 11 seconds ( as it was inserted in second-2)?

Question 2: Is it possible to set a TTL at a table level in such a way that each entry in the table will expire based on the TTL in a FIFO fashion ? (data-1 will expire at second-10 and data-2 at second-11), without specifying TTL while inserting for each data point? (Should be able to specify at a table level ?)

Thanks for the help :)

EDIT:

the page at https://docs.datastax.com/en/cql/3.1/cql/cql_using/use_expire_c.html says

Setting a TTL for a table

The CQL table definition supports the default_time_to_live property, which applies a specific TTL to each column in the table. After the default_time_to_live TTL value has been exceed, Cassandra tombstones the entire table. Apply this default TTL to a table in CQL using CREATE TABLE or ALTER TABLE

they say "entire table" which confused me.

avinash
  • 49
  • 2
  • 6

3 Answers3

3

TTL at table level is by no means different than TTL at values level: it specifies the default TTL time for each row.

The TTL specifies after how many seconds the values must be considered outdated and thus deleted. The reference point is the INSERT/UPDATE timestamp, so if you insert/update a row at 09:53:01:

  • with a TTL of 10 seconds, it will expire at 09:53:11
  • with a TTL of 15 seconds, it will expire at 09:53:16
  • with a TTL of 0 seconds, it will never expire

You can override the default TTL time by specifying USING TTL X clause in your queries, where X is your new TTl value.

Please note that using TTL not wisely can cause tombstones problems. And note also that the TTL usage have some quirks. Have a look at this recent answer for further details.

Community
  • 1
  • 1
xmas79
  • 5,060
  • 2
  • 14
  • 35
  • The phrase 'entire table will be tombstoned' is what confused me, too, and I've yet to see anyone explain what they mean by that, because it seems to imply it's more than just a default TTL value for new rows. – InfinitiesLoop Jul 13 '17 at 20:30
2

Question 1 Ans : data1 will deleted after 10 and data2 will deleted after 11 seconds

Question 2 Ans : Cassandra insert every column with the table's ttl, So Every column will expire on insertion time + ttl.

Ashraful Islam
  • 12,470
  • 3
  • 32
  • 53
0

I read this topic and a lot of anothers but I'm still confused because at https://docs.datastax.com/en/cql-oss/3.3/cql/cql_using/useExpire.html

they say exactly this:

If any column exceeds TTL, the entire table is tombstoned.

What do they mean? I understand that there is no any sence to tombstone all columns in table when only one exceeded default_time_to_live but they wrote exactly this!

UPD: I did several tests. default_time_to_live means just default TTL on column level. When this TTL expires just concrete columns with expired TTL are tombstoned.

They used very strange sentence in that article.

Donz
  • 1,389
  • 1
  • 13
  • 21