cassandra - 如何从 cassandra 中删除数据

标签 cassandra cql

我使用的是Cassandra 3.6数据库,表定义是这样的。

CREATE TABLE sg.products (
    date_updated text,
    time_added int,
    id text,
    best_seller text,
    company text,
    PRIMARY KEY (date_updated, time_added, id)
) WITH CLUSTERING ORDER BY (time_added ASC, id ASC)
    AND bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';

表有数百万条数据。

在“产品”表中,我删除了best_seller列,成功删除了该列。 但是当我检查空间磁盘时,它没有法令,

所以我在谷歌上查询,发现了这个词“Tombstone”,

所以 Cassandra 并没有删除数据,而是保存到墓碑中。

现在我的问题是如何删除墓碑数据?,这样我就可以节省内存。

或者有什么办法可以节省内存吗?

提前致谢。

最佳答案

墓碑掉落 仅当数据所属表中定义的 local_delete_time + gc_grace_seconds 之后,Cassandra 才会在压缩触发时完全删除这些逻辑删除。请记住,所有节点都应该在 gc_grace_seconds 内修复,以确保逻辑删除的正确分布并防止已删除的数据再次出现。

关于cassandra - 如何从 cassandra 中删除数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50001303/

相关文章:

cassandra - 按日期检索行 : cassandra

cassandra - Cassandra 可以保存空列表吗?

java - 通过 Java + Spark + SparkSession 在 Cassandra 表中插入/更新行的最佳方法是什么

java - 带有连字符 (-) 的 Cassandra Keyspace 名称

cassandra - 从 cassandra 数据文件夹中恢复所有键空间和表

java - 通过 Spark 进行 Cassandra 数据聚合

java - 如何建立 Cassandra 连接

cassandra - 驱动程序 datastax 驱动程序分页何时产生的页面少于请求的页面?

Cassandra cqlsh 查询失败,没有错误

database - 具有幂等增长运算符的最终一致性分布式数据库?