Cassandra tombstones count multiple queries vs single query

て烟熏妆下的殇ゞ 提交于 2020-01-23 13:18:07

问题


I've a cassandra table definition as following

CREATE TABLE mytable
(
  colA text,
  colB text,
  timeCol timestamp,
  colC text,
  PRIMARY KEY ((colA, colB, timeCol), colC)
) WITH....

I want to know if number of tombstones would vary between following types of queries:

1. delete from mytable where colA = '...' AND colB = '...' and timeCol = 111

Above query affect multiple records, (multiple values of colC)

2. delete from mytable where colA = '...' AND colB = '...' and timeCol = 111 AND colC = '...'

However, 2nd query needs to be executed for each value of last column colC, while 1st query takes care of deletion in one execution

Will Cassandra create same number of tombstones in both the cases?


回答1:


Cassandra will create a single tombstone for each delete statement. However, each statement will create a different type of tombstone.

1. delete from mytable where colA = '...' AND colB = '...' and timeCol = 111

Will create a row level tombstone:

{ "key": "00032e2e2e0000032e2e2e000008000000000000006f00", "metadata": { "deletionInfo": { "markedForDeleteAt":1427461335167000,"localDeletionTime":1427461335 } }, "columns": [] }

Row level tombstones will make sure all columns will be covered with the delete.

2. delete from mytable where colA = '...' AND colB = '...' and timeCol = 111 AND colC = '...'

Creates a column tombstone:

{ "key": "00032e2e2e0000032e2e2e000008000000000000006f00", "columns": [["...","...:!",1427461572135000,"t",1427461572]] }

This will only delete values that have been saved under this clustering key.



来源:https://stackoverflow.com/questions/29299662/cassandra-tombstones-count-multiple-queries-vs-single-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!