gpt4 book ai didi

cassandra - default_time_to_live 如何删除 Cassandra 中没有墓碑的行?

转载 作者:行者123 更新时间:2023-12-03 14:02:48 27 4
gpt4 key购买 nike

来自 How is data deleted?

Cassandra allows you to set a default_time_to_live property for an entire table. Columns and rows marked with regular TTLs are processed as described above; but when a record exceeds the table-level TTL, Cassandra deletes it immediately, without tombstoning or compaction.



这也回答了 here

If a table has default_time_to_live on it then rows that exceed this time limit are deleted immediately without tombstones being written.



并在 LastPickle 的帖子中发表评论 About deletes and tombstones

Another clue to explore would be to use the TTL as a default value if that's a good fit. TTLs set at the table level with 'default_time_to_live' should not generate any tombstone at all in C*3.0+. Not tested on my hand, but I read about this.



我已经使用 LeveledCompactionStrategy 做了我能想象到的最简单的测试:
CREATE KEYSPACE IF NOT EXISTS temp WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};

CREATE TABLE IF NOT EXISTS temp.test_ttl (
key text,
value text,
PRIMARY KEY (key)
) WITH compaction = { 'class': 'LeveledCompactionStrategy'}
AND default_time_to_live = 180;
  • INSERT INTO temp.test_ttl (key,value) VALUES ('k1','v1');
  • nodetool flush temp
  • sstabledump mc-1-big-Data.db enter image description here
  • 等待 180 秒(default_time_to_live)
  • sstabledump mc-1-big-Data.db enter image description here
    墓碑尚未创建
  • nodetool compact temp
  • sstabledump mc-2-big-Data.db enter image description here
    墓碑创建 (并且由于 gc_grace_seconds 而没有被压缩)

  • 测试使用 apache cassandra 3.0.13

    从这个例子中我得出结论, default_time_to_live 不是真的。不需要墓碑,至少对于版本 3.0.13。
    然而,这是一个非常简单的测试,我正在强制使用 nodetool compact 进行重大压缩。所以我可能不会重现 default_time_to_live 魔法发挥作用的场景。

    但是,如果没有墓碑,C* 将如何删除呢?为什么这应该与每次插入使用 TTL 不同?

    最佳答案

    我被您在我们的博客 (The Last Pickle Blog) 上回答这个问题时提到的文档所迷惑。我可能回答这个问题太快了,尽管我写了一个“探索”的东西,甚至说我没有明确地尝试过。

    Another clue to explore would be to use the TTL as a default value if that's a good fit. TTLs set at the table level with 'default_time_to_live' should not generate any tombstone at all in C*3.0+. Not tested on my hand, but I read about this.



    所以我上面的句子是错误的。基本上,默认值可以在查询级别被 TTL 覆盖,我不知道 Cassandra 如何在没有墓碑的情况下处理这个问题。

    From the example I conclude that isn't true that default_time_to_live not require tombstones, at least for version 3.0.13.



    另外,我很高兴看到您不相信我或 Datastax 文档,而是自己尝试了。这绝对是正确的方法。

    But how would C* delete without tombstones? Why this should be a different scenario to using TTL per insert?



    是的,正是这个,

    干杯。

    阿兰·罗德里格斯 - @arodream - alain@thelastpickle.com
    法国/西类牙

    最后的泡菜 - Apache Cassandra Consulting
    http://www.thelastpickle.com

    关于cassandra - default_time_to_live 如何删除 Cassandra 中没有墓碑的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52282517/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com