![](/img/trans.png)
[英]will composite partition & compound key affect perfomance in cassandra?
[英]Select from multiple partitions in Cassandra, with a composite partition key?
在 Cassandra (CQL) 中,可以查詢多個分區,例如:
create table foo(i int, j int, primary key (i));
insert into foo (i, j) values (1, 1);
insert into foo (i, j) values (2, 2);
select * from foo where i in (1, 2);
i | j
---+---
1 | 1
2 | 2
但是,如果foo
有一個復合分區鍵,我不確定它是否可能:
create table foo(i int, j int, k int, primary key ((i, j), k));
我嘗試過的一些 CQL 拒絕的查詢是:
select * from foo where (i = 1 and j = 1) or (i = 2 and j = 2);
select * from foo where (i, j) in ((1, 1), (2, 2));
我也試過:
select * from foo where i in (1, 2) and j in (1, 2);
但這對查詢來說太寬了,因為這也會返回 (i=1, j=2) 或 (i = 2, j=1) 的值。
可以使用 DSE Java 驅動程序從客戶端查詢 in 子句。您必須使用異步選項https://docs.datastax.com/en/developer/java-driver/4.10/manual/core/async/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.