Overwrite the string in cassandra using INSERT, will this cause a gravestone?

Writing data to Kassandra without creating tombstones over them is vital in our case because of the amount of data and speed. Currently, we only wrote a line once, and then never needed to update the line again, but only to get the data again.

Now there was a case when we really need to write data, and then complete it with a lot of data, which will be completed after a while. This can be done either:

  • overwrite all the data in the row again using INSERT (all data is available) or

  • Performing updates only on new data.

What is the best way to do this, be mindful of speed and don't create a tombstone? [/ p>

+7
cassandra tombstone
source share
2 answers

Tombstones are created only when deleting data or using TTL values.

Cassandra is very suitable for your described use case. Adding data incrementally will work for both INSERT and UPDATE statements. Cassandra will store data in different places if data is added over time for the same partition key. Periodically performed compilations again combine data for one key to optimize access and free disk space. This will happen based on the timestamp of the written meanings, but does not create any new tombstones. You can learn more about how Cassandra stores data, for example. here .

+7
source share

It would be better to update to add new or changed data. There is no need to rewrite old data that does not change, and it would be inefficient to force Cassandra to rewrite it.

When you insert or update, Cassandra saves the change timestamp for each column. When you read, Cassandra collects all records for this key from memory, from disk and other replicas depending on the consistency setting. It will then combine the column data so that the newest value is used for each column.

When data is compressed on disk, if there are separate updates for different columns of a row, they will be merged into one row in the compressed data.

You do not have to worry about creating tombstones by performing an update if you are not using the update to set the TTL (Time To Live) value. In your application, it sounds like you never delete data, so you will never have tombstones.

+2
source share

All Articles