使用cassandra上的复合键在有限查询中排序

时间:2014-06-21 15:47:52

标签: cassandra time-series composite-key composite-primary-key in-clause

在以下情形中:

CREATE TABLE temperature_by_day (
   weatherstation_id text,
   date text,
   event_time timestamp,
   temperature text,
   PRIMARY KEY ((weatherstation_id,date),event_time)
)WITH CLUSTERING ORDER BY (event_time DESC);

INSERT INTO temperature_by_day(weatherstation_id,date,event_time,temperature)
VALUES ('1234ABCD','2013-04-03','2013-04-03 07:01:00','72F');

INSERT INTO temperature_by_day(weatherstation_id,date,event_time,temperature)
VALUES ('1234ABCD','2013-04-03','2013-04-03 08:01:00','74F');

INSERT INTO temperature_by_day(weatherstation_id,date,event_time,temperature)
VALUES ('1234ABCD','2013-04-04','2013-04-04 07:01:00','73F');

INSERT INTO temperature_by_day(weatherstation_id,date,event_time,temperature)
VALUES ('1234ABCD','2013-04-04','2013-04-04 08:01:00','76F');

如果我执行以下查询:

SELECT *
FROM temperature_by_day
WHERE weatherstation_id='1234ABCD'
AND date in ('2013-04-04', '2013-04-03') limit 2;

我意识到cassandra的结果是由clausa IN中相同的patkeys序列排序的。在这种情况下,我想知道预期结果是否总是“2013-04-04”当天的两个记录?即使在具有多个节点的场景中,即Cassadra在结果排序中是否遵守IN子句的顺序?

0 个答案:

没有答案