【发布时间】:2015-09-06 07:38:46
【问题描述】:
我正在尝试了解具有聚类键的元组运算符的行为。这是我想要做的:
create table sampletable (a int,b int,c int, d int, e int, primary key((a,b,c),d,e));
insert into sampletable(a,b,c,d,e) values(1,1,1,1,1);
insert into sampletable(a,b,c,d,e) values(1,1,1,1,1);
insert into sampletable(a,b,c,d,e) values(1,1,1,1,2);
insert into sampletable(a,b,c,d,e) values(1,1,2,1,1);
insert into sampletable(a,b,c,d,e) values(1,1,2,1,2);
insert into sampletable(a,b,c,d,e) values(1,1,2,2,3);
insert into sampletable(a,b,c,d,e) values(1,1,2,1,2);
insert into sampletable(a,b,c,d,e) values(1,1,1,2,3);
cqlsh:mapro> select * from sampletable;
a | b | c | d | e
---+---+---+---+---
1 | 1 | 1 | 1 | 1
1 | 1 | 1 | 1 | 2
1 | 1 | 1 | 2 | 3
1 | 1 | 2 | 1 | 1
1 | 1 | 2 | 1 | 2
1 | 1 | 2 | 2 | 3
(6 rows)
-- Query1
cqlsh:mapro> select * from sampletable where a=1 and b=1 and c in (1,2) and (d,e)<(2,3);
a | b | c | d | e
---+---+---+---+---
1 | 1 | 1 | 1 | 1
1 | 1 | 1 | 1 | 2
1 | 1 | 2 | 1 | 1
1 | 1 | 2 | 1 | 2
(4 rows)
-- Query2
cqlsh:mapro> select * from sampletable where a=1 and b=1 and c in (1,2) and (d,e)<(2,9);
a | b | c | d | e
---+---+---+---+---
1 | 1 | 1 | 1 | 1
1 | 1 | 1 | 1 | 2
1 | 1 | 1 | 2 | 3
1 | 1 | 2 | 1 | 1
1 | 1 | 2 | 1 | 2
1 | 1 | 2 | 2 | 3
(6 rows)
我无法理解为什么查询 2 返回的结果与查询 1 不同。我的理解是 Cassandra 将首先应用所有分区键过滤,然后尝试应用元组排序,即 (d,e)
【问题讨论】: