Search code examples
cassandradatastaxcql

Does add new value/update existing value in map in cassandra create tombstones?


I was following this page of datastax :- https://docs.datastax.com/en/cql-oss/3.3/cql/cql_using/useInsertMap.html to find how to update the map in cassandra. But I am suspicious if this does not create unwanted tombstones in following scenarios :-

  1. UPDATE cycling.cyclist_teams SET teams = teams + {2009 : 'DSB Bank - Nederland bloeit'} WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e

Will adding new value to map (if 2009 was not existed in map) create any tombstone ?

  1. UPDATE cycling.cyclist_teams SET teams = teams + {2009 : 'DSB Bank - Nederland bloeit'} WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2

Will updating old value to map (if 2009 key was existed before in map) create tombstone for old value or any other kind of tombstone?


Solution

  • It won't create a tombstone (no delete or deliberate write of null), but it will "obsolete" the previous value.

    This means that both the old and new values for 2009 will be retrieved at read-time, and Cassandra will filter-out all but the most recent. Also, depending on how much time has elapsed since the first write to teams, it entirely possible that the old and new values could have been written to separate SSTable files, meaning that the read/reconciliation process will take longer.

    So while this won't create a tombstone, it'll have a similar effect in that a large amount of obsoleted data (from in-place writes/updates) to the same value will cause performance to slow over time.