Which version of Cassandra are you using? If this is a 3.0 or higher, why don't you create a materialized view for ypur base table with the last time as the first clustering colum?
However : It need to be confirmed if this is not an anti-pattern for cassandra as this materialized view will have a lot delete + insert (i.e lots of tombstone i think) Le 8 nov. 2016 7:49 AM, "Dikang Gu" <dikan...@gmail.com> a écrit : > > Agree, change the last_time to be descending order will help, you can also TTL the data, so that the old records will be purged by Cassandra. > > --Dikang. > > On Mon, Nov 7, 2016 at 10:39 PM, Alain Rastoul <alf.mmm....@gmail.com> wrote: >> >> On 11/08/2016 03:54 AM, ben ben wrote: >>> >>> Hi guys, >>> CREATE TABLE recent ( >>> user_name text, >>> vedio_id text, >>> position int, >>> last_time timestamp, >>> PRIMARY KEY (user_name, vedio_id) >>> ) >>> >> >> Hi Ben, >> >> May be a clustering columns order would help >> CREATE TABLE recent ( >> ... >> ) WITH CLUSTERING ORDER BY (last_time DESC); >> So you can query only the last 10 records >> SELECT * FROM recent WHERE vedio_id = xxx LIMIT 10 >> >> See here http://www.datastax.com/dev/blog/we-shall-have-order >> -- >> best, >> Alain > > > > > -- > Dikang >