使用 hector 更快地计算 cassandra 行中的列总数

发布于 2024-12-24 03:27:39 字数 476 浏览 7 评论 0原文

我想使用 Hector 客户端计算 Cassandra 行的总列数。目前我正在使用 CountQuery 执行此操作,但对我来说似乎非常慢。同样,对于只有 60k 列的行,需要花费近 2 秒的时间。我的代码目前如下所示:

QueryResult<Integer> qr = HFactory.createCountQuery(ksp, se, se).
    setColumnFamily("ColumnFamily1").
    setKey("RowKey").
    setRange(null, null, 1000000000).execute();

PS:我必须将范围设置为如此高的数字,否则它只计算我的最大值。到我在范围内提供的数字。

我有什么想法可以改进这个吗?

I want to count the total number of columns for a Cassandra row using Hector client. Currently I am doing this with a CountQuery, but it seems really slow to me. Also for a row, with just 60k columns it's taking nearly 2 seconds. My code currently looks like this:

QueryResult<Integer> qr = HFactory.createCountQuery(ksp, se, se).
    setColumnFamily("ColumnFamily1").
    setKey("RowKey").
    setRange(null, null, 1000000000).execute();

PS: I have to set the range to such a high number, otherwise it only counts me max. to the number I've provided in the range.

Any ideas how I can improve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戴着白色围巾的女孩 2024-12-31 03:27:39

Cassandra 中的列计数本质上很慢。 Cassandra 必须迭代整行才能返回计数。

您可能想要对计数进行非规范化。您可以使用每次插入时都会更新的计数器列。

Counting columns in Cassandra is inherently slow. Cassandra has to iterate over the whole row in order to return the count.

You probably want to denormalize the count. You could use a counter column which you update every time you insert.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文