Cassandra cqlsh无法与非分区键上的where子句一起使用 [英] Cassandra cqlsh not working with where clause on non-partition key

查看:75
本文介绍了Cassandra cqlsh无法与非分区键上的where子句一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表描述为:

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子句中并出现错误,可能是什么原因?

But if I am putting non partition key in where clause getting below error.What can be the reason ?

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中,您需要采用基于查询的建模方法。解决此问题的最佳方法是使用专门为该查询服务的表

In Cassandra you need to take a query-based modeling approach. The best way to solve this problem is with a table that is specifically designed to serve that query.

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)
); 

这将起作用,它将很好地分布,并且不需要进行全表扫描允许过滤

That will work, it will distribute well, and it won't require the full table scans that accompany ALLOW FILTERING.


是的,我正在做 cqlsh- -connect-timeout = 100000000 --request-timeout = 10000000000

我无法警告您做到这一点就足够了。这些超时默认值存在是有原因的。它们可保护您的群集/节点不会因查询性能不佳而翻倒。当您遇到问题并想增加查询超时时间时,请仔细查看您的查询,看看是否有更好的方法来构建它。

I can't warn you against doing this enough. Those timeout defaults exist for a reason. They protect your cluster/nodes from tipping over due to bad performing queries. When you are faced with a problem and tempted to increase the query timeouts, take a closer look at your query and see if there's a better way to build it.

这篇关于Cassandra cqlsh无法与非分区键上的where子句一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆