Cassandra tombstones计算多个查询与单个查询

时间:2015-03-27 11:29:09

标签: cassandra cql cassandra-2.0 cql3

我的cassandra表定义如下

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

我想知道以下类型的查询之间的墓碑数量是否会有所不同:

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

以上查询会影响多条记录(colC的多个值)

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

但是,需要对最后一列colC的每个值执行第二次查询,而第一次查询在一次执行中负责删除

Cassandra会在两种情况下创建相同数量的墓碑吗?

1 个答案:

答案 0 :(得分:2)

Cassandra将为每个删除语句创建一个逻辑删除。但是,每个语句都会创建一个不同类型的墓碑。

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

将创建一个行级逻辑删除:

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

行级逻辑删除将确保删除所有列。

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

创建列逻辑删除:

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

这将仅删除已在此群集密钥下保存的值。