Deleting data
We have established that Cassandra employs a log-structured storage engine, where all writes are immutable appends to the log. The implication is that data cannot actually be deleted at the time a DELETE
statement is issued. Cassandra solves this by writing a marker, called a tombstone, with a timestamp greater than the previous value. This has the effect of overwriting the previous value with an empty one, which will then be compiled in subsequent queries for that column in the same manner as any other update.
Garbage collection
Eventually, these tombstones are reconciled with earlier values as part of the compaction process, where the earlier values are discarded. See Chapter 7, Modeling for Availability for more details on how compaction works. There are two possibilities for when data can be physically deleted and tombstones collected.
If a delete occurs while the data is still in the memtable (and therefore, not yet flushed to disk), the existing data will be immediately...