【发布时间】:2023-03-03 06:12:22
【问题描述】:
我的用例
我想按时间戳 DESC 排序结果。但我不希望时间戳成为主键中的第二列,因为这会占用我的查询能力
例如
create table demo(oid int,cid int,ts timeuuid,PRIMARY KEY (oid,cid,ts)) WITH CLUSTERING ORDER BY (ts DESC);
需要查询:
I want the result for all the below queries to be in DESC order of timestamp
select * from demo where oid = 100;
select * from demo where oid = 100 and cid = 10;
select * from demo where oid = 100 and cid = 100 and ts > minTimeuuid('something');
我正在尝试使用 CQL 中的 CLUSTERING ORDER 创建此表并收到此错误
cqlsh:v> create table demo(oid int,cid int,ts timeuuid,PRIMARY KEY (oid,cid,ts)) WITH CLUSTERING ORDER BY (ts desc);
Bad Request: Missing CLUSTERING ORDER for column cid
在本文档中,它提到我们可以有多个键用于集群排序。有人知道怎么做吗?
【问题讨论】: