java 读取 cassandra 大表_java – Cassandra表中快速估计的行数

我很惊讶以前没有提出这个问题.

假设我们在cassandra中有一个巨大的表,我们需要在其中获得估计的行数(不精确,只是近似).

显然,从表中选择简单计数(*)效率不高,可能需要很长时间.我们需要一些又脏又快的东西.

Datastax博客建议the following:

I don’t care about the exact number, can I have a ballpark estimate?

Because Cassandra knows how many rows there are in each SSTable it is

possible to get an estimate. The ‘nodetool cfstats’ output tells you

these counts in the ‘Number of Keys (estimate)’ line. This is the sum

of rows in each SStable (again approximate due to the indexing used

but can’t be off by more than 128 by default).

附:我不能改变表结构或其他什么.考虑我使用遗留架构.换句话说,我对添加计数器或其他特殊字段等变通方法不感兴趣.

解决方法:

Cassandra也通过JMX暴露了近似计数(从“nodetool cfstats”获得).代码可以挂钩到此JMX度量标准,以编程方式获取计数.

EstimatedPartitionCount Gauge Approximate number of keys in

table.

{

"type": "READ",

"mbean": "org.apache.cassandra.metrics:type=Table,keyspace=*,scope=*,name=*",

"attribute": "Count"

}

这是所有JMX指标暴露的link.

标签:datastax-java-driver,java,cassandra

来源: https://codeday.me/bug/20190823/1697982.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值