Cassandra 中列族的行数 [英] Row count of a column family in Cassandra

查看:24
本文介绍了Cassandra 中列族的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 Cassandra 中获取单个列族的行数(键数)?get_count 只能用于获取列数.

Is there a way to get a row count (key count) of a single column family in Cassandra? get_count can only be used to get the column count.

例如,如果我有一个包含用户的列族并想获取用户数.我怎么能做到?每个用户都有自己的一行.

For instance, if I have a column family containing users and wanted to get the number of users. How could I do it? Each user is it's own row.

推荐答案

如果您正在处理大型数据集并且可以使用相当好的近似值,我强烈建议您使用以下命令:

If you are working on a large data set and are okay with a pretty good approximation, I highly recommend using the command:

nodetool --host <hostname> cfstats

这将为每个列族输出一个列表,如下所示:

This will dump out a list for each column family looking like this:

Column Family: widgets
SSTable count: 11
Space used (live): 4295810363
Space used (total): 4295810363
Number of Keys (estimate): 9709824
Memtable Columns Count: 99008
Memtable Data Size: 150297312
Memtable Switch Count: 434
Read Count: 9716802
Read Latency: 0.036 ms.
Write Count: 9716806
Write Latency: 0.024 ms.
Pending Tasks: 0
Bloom Filter False Postives: 10428
Bloom Filter False Ratio: 1.00000
Bloom Filter Space Used: 18216448
Compacted row minimum size: 771
Compacted row maximum size: 263210
Compacted row mean size: 1634

键数(估计)"行是整个集群的一个很好的猜测,性能比显式计数方法快得多.

The "Number of Keys (estimate)" row is a good guess across the cluster and the performance is a lot faster than explicit count approaches.

这篇关于Cassandra 中列族的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆