gpt4 book ai didi

Cassandra cqlsh 不适用于非分区键的 where 子句

转载 作者:行者123 更新时间:2023-12-03 01:35:09 26 4
gpt4 key购买 nike

我的表格描述是:

CREATE TABLE user (
id text,
CustID int static,
UpdateDate date,
DateOfBirth date static,
Gender text static,
Address text static,
City text static,
State text static,
Zip text static,
Email text static,
Phone text static,
OverallAssets double,
PRIMARY KEY (id,UpdateDate)
);

select * from user is working fine.

select * from user where partition key is also working fine.

但是,如果我将非分区键放入 where 子句中,则会出现以下错误。原因可能是什么?

ReadFailure: Error from server: code=1300 [Replica(s) failed to execute 
read] message="Operation failed - received 0 responses and 1 failures" info=
{'failures': 1, 'received_responses': 0, 'required_responses': 1,
'consistency': 'ONE'}

最佳答案

select * from user where CustID =0 allow filtering;

在 Cassandra 中,您需要采用基于查询的建模方法。解决此问题的最佳方法是使用专门设计用于服务该查询的表。

CREATE TABLE users_by_custid (
id text,
CustID int,
UpdateDate date,
DateOfBirth date static,
Gender text static,
Address text static,
City text static,
State text static,
Zip text static,
Email text static,
Phone text static,
OverallAssets double,
PRIMARY KEY (cust_id,id,UpdateDate)
);

这会起作用,它会很好地分发,并且不需要ALLOW FILTERING伴随的全表扫描。

Yes I am doing cqlsh --connect-timeout=100000000 --request-timeout=10000000000

我无法充分警告您不要这样做。这些超时默认值的存在是有原因的。它们可以保护您的集群/节点免于因执行不良的查询而翻倒。当您遇到问题并想增加查询超时时,请仔细查看您的查询,看看是否有更好的方法来构建它。

关于Cassandra cqlsh 不适用于非分区键的 where 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43367076/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com