【发布时间】:2018-07-11 01:53:28
【问题描述】:
我需要从 Cassandra 中的一个非常大的数据集中进行计数,超过 1 亿。如果我只运行以下查询,我担心 cassandra 会占用内存。
从 conv_org 中选择 count(*),其中 org_id = 'TEST_ORG'
有人告诉我可以使用 cassandra 自动分页来执行此操作?这似乎是一个不错的选择?
语法会像这样吗?
Statement stmt = new SimpleStatement("select count(*) from conv_org where org_id = 'TEST_ORG'");
stmt.setFetchSize(1000);
ResultSet rs = session.execute(stmt);
我不确定上面的代码是否有效,因为我不需要返回结果集,我只需要计数。
这是数据模型。
CREATE TABLE ts.conv_org (
org_id text,
create_time timestamp,
test_id text,
org_type int,
PRIMARY KEY (org_id, create_time, conv_id)
)
【问题讨论】: