question

mishra.anurag643_153409 avatar image
mishra.anurag643_153409 asked Erick Ramirez answered

Why is COUNT() returning a different value every time?

I am running count(*) on table in cqlsh and it is returning different value every time .

cqlsh:keyspace> select count(1) from table_name;

 count
--------
 760912

(1 rows)

Warnings :
Aggregation query used without partition key

cqlsh:keyspace> select count(1) from table_name;

 count
--------
 760901

(1 rows)

I have 3 nodes of cassandra cluster and replication factor = 1 . I believe since rf = 1 , setting consistency does not make any difference ? though setting consistency level = All also giving same issue .

count
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

Unless your application is switched off, chances are the data is getting updated whenever you perform a count.

For a detailed explanation, I've explained Why COUNT() is bad in Cassandra. Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.