问题描述
这是一个非常基本的问题,但实际上困扰了我好几天。是否有一种好方法来获得与Cassandra中给定表的 COUNT(*)
等效的方法?
This is a super basic question but it's actually been bugging me for days. Is there a good way to obtain the equivalent of a COUNT(*)
of a given table in Cassandra?
我将把几亿行移到C *中以进行一些负载测试,并且我希望至少在某些示例ETL作业之前获得行数我在网络上移动了大量数据。
I will be moving several hundreds of millions of rows into C* for some load testing and I'd like to at least get a row count on some sample ETL jobs before I move massive amounts of data over the network.
我最好的主意是基本上使用Python遍历每一行并自动递增计数器。有没有更好的方法来确定(甚至估计)C *表的行大小?我还浏览了Datastax Ops Center,看看是否可以确定该行的大小。如果可以,我不知道怎么可能。
The best idea I have is to basically loop over each row with Python and auto increment a counter. Is there a better way to determine (or even estimate) the row size of a C* table? I've also poked around Datastax Ops Center to see if I can determine the row size there. If you can, I don't see how it's possible.
需要其他任何人来获得 count(*)
C *中的表格?如果是这样,您将如何去做?
Anyone else needed to get a count(*)
of a table in C*? If so, how'd you go about doing it?
推荐答案
是的,您可以使用 COUNT(*)
。这是
Yes, you can use COUNT(*)
. Here's the documentation.
计算用户表中的行数:
SELECT COUNT(*) FROM users;
这篇关于如何获取Cassandra表中的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!