cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alain Rastoul <alf.mmm....@gmail.com>
Subject Re: A difficult data model with C*
Date Tue, 08 Nov 2016 06:39:30 GMT
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

Mime
View raw message