read time out in cassandra in django cassandra engine

359 Views Asked by At

Hi i'm using cassandra in python. i have a table in cassandra with line_id (uuid) as it's primary key. I have about 2000000 records(each partition has one record). when i want to get the count of records:

NumberPartitionedLine.objects.count()

i get this error:

Error from server: code=1200 [Coordinator node timed out waiting for replica nodes' responses] message="Operation timed out - received only 0 responses." info={'consistency': 'LOCAL_ONE', 'received_responses': 0, 'required_responses': 1}

also when i run the query select count(*) from number_partitioned_line in razorsql or datagrip, i get timeout error and cant get the resutl. whats the reason?

1

There are 1 best solutions below

0
M P On

You are trying to read from 2 million partitions and which is really not recommended in Cassandra.

doing a count(*) will add a lots of pressure on the nodes if its not restricted by partition key and in your case you cannot restrict by partition as each partition only has one record.

Better would be to use a counter table in your case - https://docs.datastax.com/en/cql/3.3/cql/cql_using/useCountersConcept.html

You could tweak the memory allocation or increase timeout in yaml etc but it will only help in pushing the problem to later.