通过部分分区键查询Cassandra [英] Querying Cassandra by a partial partition key

查看:604
本文介绍了通过部分分区键查询Cassandra的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Cassandra中,我可以创建一个与我的聚类键分开的复合分区键:

In Cassandra, I can create a composite partition key, separate from my clustering key:

CREATE TABLE footable (
    column1 text,
    column2 text,
    column3 text,
    column4 text,
    PRIMARY KEY ((column1, column2))
)

根据我的理解,分区键查询是一个非常高效(最有效?)的方法检索数据。但是,我不知道是否只通过复合分区键的一部分进行查询也是有效的。

As I understand it, quering by partition key is an extremely efficient (the most efficient?) method for retrieving data. What I don't know, however, is whether it's also efficient to query by only part of a composite partition key.

在MSSQL中,这将是高效的,因为组件包括从第一个开始(column1,而不是column2,在这个例子中)。 Cassandra也是这样吗?

In MSSQL, this would be efficient, as long as components are included starting with the first (column1 instead of column2, in this example). Is this also the case in Cassandra? Is it highly efficient to query for rows based only on column1, here?

推荐答案

在Cassandra中不是这样,因为它是非常高效的不可能。否则会产生以下错误:

This is not the case in Cassandra, because it is not possible. Doing so will yield the following error:


分区键部件实体必须受到限制,因为前一部分

Partition key part entity must be restricted since preceding part is

查看这篇来自DataStax MVP Robbie Strickland的Cassandra 2014 SF Summit演讲,题为在Hood下的CQL 。幻灯片62-64显示完整的分区键用作rowkey。使用Cassandra中的复合分区键,您必须查询所有的rowkey或其中没有。

Check out this Cassandra 2014 SF Summit presentation from DataStax MVP Robbie Strickland titled "CQL Under the Hood." Slides 62-64 show that the complete partition key is used as the rowkey. With composite partitioning keys in Cassandra, you must query by all of the rowkey or none of it.

您可以观看在此处完成演示视频

这篇关于通过部分分区键查询Cassandra的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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