Cassandra NodeTool cfstats 计数

Cassandra NodeTool cfstats count

我像这样创建了一个 cassandra table,有很多信息:

CREATE TABLE keyspace.table1 (
uuid blob,
id bigint,
timestamp bigint,
description text,
option1 double,
PRIMARY KEY (uuid, id) ) WITH CLUSTERING ORDER BY (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'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
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 = '99.0PERCENTILE';

我正在尝试 运行 对其使用 nodetool cfstats 以确定行数。我在网上搜索了一下,似乎键的数量(估计)应该是行数。但是,数字非常低,如下所示,所以我知道这是不对的。我做错了什么?

Table: table1
    SSTable count: 3
    Space used (live): 195.02 MB
    Space used (total): 195.02 MB
    Space used by snapshots (total): 567.99 KB
    Off heap memory used (total): 61.83 KB
    SSTable Compression Ratio: 0.3936987749701019
    Number of keys (estimate): 19
    Memtable cell count: 612048
    Memtable data size: 14.18 MB
    Memtable off heap memory used: 0 bytes
    Memtable switch count: 6
    Local read count: 2657130
    Local read latency: 0.055 ms
    Local write count: 2409743
    Local write latency: 0.017 ms
    Pending flushes: 0
    Bloom filter false positives: 0
    Bloom filter false ratio: 0.00000
    Bloom filter space used: 64 bytes
    Bloom filter off heap memory used: 40 bytes
    Index summary off heap memory used: 84 bytes
    Compression metadata off heap memory used: 61.71 KB
    Compacted partition minimum bytes: 49.82 KB
    Compacted partition maximum bytes: 85.8 MB
    Compacted partition mean bytes: 27.06 MB
    Average live cells per slice (last five minutes): 1.0160752060827343
    Maximum live cells per slice (last five minutes): 5722
    Average tombstones per slice (last five minutes): 1.0
    Maximum tombstones per slice (last five minutes): 1

如果这不可能,是否有另一种方法来获取 table 的行数?

谢谢

从您的架构来看,您的分区键是您的 uuid 列。每个分区键都是 Cassandra 存储引擎的 "Row"。所以 cfstats 只是输出为此 table.

存储的分区键的数量(当然是估计的)

我会检查并查看您的系统中有多少个不同的 UUID,如果它在 19 左右,那么一切都很好。

它不是 "rows" 的数量,它是键或分区的数量。在您的数据模型中,它将是唯一 uuid 的数量。请注意,对于 2.0,此数字可能会有所偏差,它将汇总所有 sstables 中的分区数。 Post 2.1.6 它将合并一个 hyperloglog 结构,因此跨 sstables 的重复不会影响它。

要获取您实际需要读取数据的 CQL 行,您可以使用 count 或 spark 作业,这些都很昂贵,因此可能需要考虑保留一个带有计数器的替代 table在里面。