Server-side warning: Aggregation query used without partition key

Alexis Wilke picture Alexis Wilke · Apr 18, 2016 · Viewed 11.6k times · Source

While using the C/C++ driver of Cassandra, I at times see these kind of messages popping up in my console:

1460937092.140 [WARN] (src/response.cpp:51:char*
      cass::Response::decode_warnings(char*, size_t)):
      Server-side warning: Aggregation query used without partition key

Wondering whether someone knows what that means. What should I be looking for in my code that could generate this error, or is it just something on the server side that I have no control over?

Answer

Patrick McFadin picture Patrick McFadin · Apr 18, 2016

That warning is telling you that you are doing a select using a user defined aggregate without a partition key. That may be one that is built in like avg, count, min, max or could've one of your own.

An example:

select avg(temperature) from weather_data;

Vs

select avg(temperature) from weather_data where id = 1;

The first example would scan all rows of data in the cluster and could be a serious performance hit. If there are enough rows, the query could time out.

The second will only scan a single partition of data which keeps the query to one server and is the recommended usage.