在Django cassandra engin中读取cassandra超时

2024-06-16 09:50:10 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我在用python中的cassandra。我在cassandra中有一个表,它的主键是行id(uuid)。我有大约2000000条记录(每个分区有一条记录)。当我要获取记录数时:

NumberPartitionedLine.objects.count()

我得到这个错误:

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}

同样,当我在razorsqldatagrip中运行查询select count(*) from number_partitioned_line时, 我得到超时错误,无法得到结果。 原因是什么?你知道吗


Tags: fromidobjectsuuidcount错误记录responses
1条回答
网友
1楼 · 发布于 2024-06-16 09:50:10

您正在尝试读取200万个分区,这在Cassandra中是不推荐的。你知道吗

如果不受分区键的限制,那么进行计数(*)将给节点增加很大的压力,在您的情况下,您不能按分区限制,因为每个分区只有一个记录。你知道吗

最好在您的案例中使用counter表-https://docs.datastax.com/en/cql/3.3/cql/cql_using/useCountersConcept.html

您可以调整内存分配或增加yaml中的超时时间,但这只会有助于将问题推到以后。你知道吗

相关问题 更多 >