Cassandra warning: Aggregation query used without partition key

Viewed 675

When I run a count query against C*, I get result with a warning:

cqlsh:my_keyspace> SELECT count(*) from user;

count


 1

(1 rows)

Warnings : Aggregation query used without partition key

Warning is because C* has to do scan across all nodes.

But when I do this query:

cqlsh:my_keyspace> SELECT * FROM user;

last_name | first_name | title

-----------+------------+-------
Doe | John | Mr.

(1 rows)

This query doesn't show me a warning. Isn't this also supposed to scan all nodes?

1 Answers

Yes, both queries do a full table scan but the former uses an aggregate function while the latter doesn't.

COUNT() is an aggregate function -- it returns a final count by aggregating all rows in the query. This is the reason SELECT COUNT(*) generates a warning while SELECT * doesn't. Cheers!

Related