【发布时间】:2015-06-29 22:50:44
【问题描述】:
我使用的是 Cassandra 2.1.5。
我正在使用以下方法创建表:
create table dummy2(
id timeuuid,
time timestamp,
primary key (id, time)
) with clustering order by (time desc);
我在表中插入了四条记录:
insert into dummy2 (id, time) values (now(), 1000000);
insert into dummy2 (id, time) values (now(), 2000000);
insert into dummy2 (id, time) values (now(), 3000000);
insert into dummy2 (id, time) values (now(), 4000000);
我得到结果:
id | time
--------------------------------------+--------------------------
e1fa7a80-1e64-11e5-8bf5-55cdf06f740f | 1970-01-01 08:33:20+0800
e3bbb280-1e64-11e5-8bf5-55cdf06f740f | 1970-01-01 08:50:00+0800
e5ceb400-1e64-11e5-8bf5-55cdf06f740f | 1970-01-01 09:06:40+0800
e0719090-1e64-11e5-8bf5-55cdf06f740f | 1970-01-01 08:16:40+0800
这看起来像一个树形图顺序,或者随机...
如果我将 id 类型从“timeuuid”更改为“text”,那么排序就可以正常工作:
id | time
-------+--------------------------
hello | 1970-01-01 09:06:40+0800
hello | 1970-01-01 08:50:00+0800
hello | 1970-01-01 08:33:20+0800
hello | 1970-01-01 08:16:40+0800
这是设计使然还是错误?还是我用错了?
【问题讨论】: