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

查看:31
本文介绍了通过部分分区键查询 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 也是这种情况吗?这里只根据 column1 查询行效率高吗?

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 峰会演讲,标题为CQL 底层."幻灯片 62-64 显示完整的分区键用作行键.使用 Cassandra 中的复合分区键,您必须通过所有行键进行查询或不进行查询.

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天全站免登陆