如何在Cassandra中计算出表中键的大致数目?

如何在Cassandra中计算出表中键的大致数目?,cassandra,Cassandra,我已经看到了运行nodetool cfstats时引用的大量keyestimate,但至少在我的系统Cassandra版本3.11.3中,我没有看到: Table: XXXXXX SSTable count: 4 Space used (live): 2393755943 Space used (total): 2393755943 Space used by snapshots

我已经看到了运行nodetool cfstats时引用的大量keyestimate,但至少在我的系统Cassandra版本3.11.3中,我没有看到:

           Table: XXXXXX
            SSTable count: 4
            Space used (live): 2393755943
            Space used (total): 2393755943
            Space used by snapshots (total): 0
            Off heap memory used (total): 2529880
            SSTable Compression Ratio: 0.11501749368144083
            Number of partitions (estimate): 1146
            Memtable cell count: 296777
            Memtable data size: 147223380
            Memtable off heap memory used: 0
            Memtable switch count: 127
            Local read count: 9
            Local read latency: NaN ms
            Local write count: 44951572
            Local write latency: 0.043 ms
            Pending flushes: 0
            Percent repaired: 0.0
            Bloom filter false positives: 0
            Bloom filter false ratio: 0.00000
            Bloom filter space used: 2144
            Bloom filter off heap memory used: 2112
            Index summary off heap memory used: 240
            Compression metadata off heap memory used: 2527528
            Compacted partition minimum bytes: 447
            Compacted partition maximum bytes: 43388628
            Compacted partition mean bytes: 13547448
            Average live cells per slice (last five minutes): NaN
            Maximum live cells per slice (last five minutes): 0
            Average tombstones per slice (last five minutes): NaN
            Maximum tombstones per slice (last five minutes): 0
            Dropped Mutations: 0

使用此版本的Cassandra,是否有办法从XXXXXX中近似计算select count*?

键的数量与分区的数量相同,这也是一个估计值。如果您的分区键是主键no clustering columns,那么您将估计该节点上的行数。否则,很简单,分区键值数量的估计

-吉姆

这一点随着时间的推移而改变。不管怎样,估计的键数总是意味着分区数,这一点很明显

要估计一个大表中的行数,可以将分区数作为起点。然后,近似计算集群键组合行数的平均值,您应该能够对其进行有根据的猜测

另一种想法是,计算一行的字节大小。然后查看nodetool table直方图keyspacename.tablename输出的P50:

将分区大小的第50百分位P50除以一行的大小。这将为您提供该表返回的平均行数。然后将其乘以分区的数量,就可以得到该节点的编号


如何得到卡桑德拉一行的大小


显然,您需要删除管道分隔符和行标题之类的内容,更不用说考虑字符串和数字的大小差异,但文件的最终字节大小应该让您大致了解。

我的主键并不太复杂:它只是分区键和时间戳。但是,每个分区键可能都有一个与之相关联的时间戳变量,因此在这种方法中很难进行估计,因此我将更详细地了解您的第二个建议:如何获得Cassandra中一行的大小?@bbarker Edit make。
Percentile  SSTables     Write Latency      Read Latency    Partition Size        Cell Count
                              (micros)          (micros)           (bytes)
50%             2.00             35.43           4866.32               124                 1
$ bin/cqlsh 127.0.0.1 -u aaron -p yourPasswordSucks -e "SELECT * FROM system.local WHERE key='local';" > local.txt
$ ls -al local.txt
-rw-r--r--  1 z001mj8  DHC\Domain Users  2321 Sep 16 15:08 local.txt