select count(*) runs into timeout issues in Cassandra

Philipp Claßen picture Philipp Claßen · Apr 20, 2016 · Viewed 22.3k times · Source

Maybe it is a stupid question, but I'm not able to determine the size of a table in Cassandra.

This is what I tried:

select count(*) from articles;

It works fine if the table is small but once it fills up, I always run into timeout issues:

cqlsh:

  • OperationTimedOut: errors={}, last_host=127.0.0.1

DBeaver:

  • Run 1: 225,000 (7477 ms)
  • Run 2: 233,637 (8265 ms)
  • Run 3: 216,595 (7269 ms)

I assume that it hits some timeout and just aborts. The actual number of entries in the table is probably much higher.

I'm testing against a local Cassandra instance which is completely idle. I would not mind if it has to do a full table scan and is unresponsive during that time.

Is there a way to reliably count the number of entries in a Cassandra table?

I'm using Cassandra 2.1.13.

Answer

Oleksandr Petrenko picture Oleksandr Petrenko · Apr 21, 2016

As far as I see you problem connected to timeout of cqlsh: OperationTimedOut: errors={}, last_host=127.0.0.1

you can simple increase it with options:

 --connect-timeout=CONNECT_TIMEOUT
                       Specify the connection timeout in seconds (default: 5
                       seconds).
 --request-timeout=REQUEST_TIMEOUT
                       Specify the default request timeout in seconds
                       (default: 10 seconds).