Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which one is better to use TTL or Delete in Cassandra?

I want to remove records from Cassandra cluster after a particular time. So what Should I use TTL or manually delete?

like image 800
Rajendra Jangir Avatar asked Jan 03 '23 07:01

Rajendra Jangir


1 Answers

The answer is "it depends". Deleting data in cassandra is never free.

If you have to "DELETE" you need always to issue those queries, with TTL it's done from the moment you write the data. But by using DELETE you have more control over data deletion.

On the operation side, you should try to get your tombstones in the same sstable so once gc_grace is expired the full sstable can be dropped. Because data is only actually deleted when the sstables are compacted, even if gc_grace has passed, and a compaction didn't happen with the sstable holding the tombstone, the tombstone will not be deleted from the harddrive. This also make relevant the choice of compaction strategy for your table.

If you're also using a lot of tombstones, you should always enable: "unchecked_tombstone_compaction" at table level. You can read more about that here: https://docs.datastax.com/en/cql/3.1/cql/cql_reference/compactSubprop.html

like image 143
Carlos Rolo Avatar answered Jan 10 '23 22:01

Carlos Rolo