1

when there is too many rows in cassandra table and I run following query in cqlsh:

select count(*) from tableA 

i get this error:

OperationTimedOut: errors={}, last_host=127.0.0.1

how can i resolve this error?

reihaneh
  • 225
  • 4
  • 18
  • See this [thread](http://stackoverflow.com/questions/15238970/rpc-timeout-in-cqlsh-cassandra). – Ralf Feb 14 '16 at 12:27
  • 2
    count operation is really slow if there is a lot of partitions, increasing timeout will work to a point but you will likely want to switch to using a counter or spark. http://stackoverflow.com/a/29394935/266337 – Chris Lohfink Feb 14 '16 at 15:16
  • Since there are people I work with who are forwarding this post to me as something they want done, I feel compelled to mention that increasing the query timeouts in a production cluster is a **terrible, terrible idea.** – Aaron Feb 14 '18 at 13:51

3 Answers3

4

For Cassandra 2.0.15+, 2.1.5+, use request_timeout option.

Edit ~/.cassandra/cqlshrc

[connection]
request_timeout = 20

Refer to this: https://docs.datastax.com/en/cql/3.1/cql/cql_reference/cqlshrc.html#clqshrc__cql-option

0

chris link is perfect, i had the same problem for counting the total no of records. one way is to use high limit and keep reducing it till the timeout error is resolved.

select count(*) from usertable limit 1000000;

Gomes
  • 3,330
  • 25
  • 17
-1

I think you can create cqlshrc file in ~/.cassandra and set client_timeout option in seconds.

~/.cassandra/cqlshrc

[connection]
client_timeout = 30
grzesiekw
  • 477
  • 4
  • 8