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?
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