How to choose the last record from the time series in Kassandra?

I want to save some encoded "data" in cassadra, with the timestamp version. My preliminary scheme:

CREATE TABLE items (
  item_id varchar,
  timestamp timestamp,
  data blob,
  PRIMARY KEY (item_id, timestamp)
); 

I would like to be able to return a list of items, returning only the last (highest timestamp) for each item_id; Is this possible with this scheme?

+3
source share
1 answer

It is not possible to express such a query in a single CQL expression for this table, so there is no answer.

You can try to create another table, for example. latest_items, and only save the latest update there, so the scheme will look like this:

CREATE TABLE latest_items (
  item_id varchar,
  timestamp timestamp,
  data blob,
  PRIMARY KEY (item_id)
); 

timestamp order, , , . select * from latest_items limit 10000000;. , , , , , , , .

, Cassandra. blob, , URL- - .

+1

All Articles