cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laing, Michael" <>
Subject Re: How would you model that?
Date Fri, 08 Nov 2013 11:45:34 GMT
You could try this:

CREATE TABLE user_activity (shard text, user text, ts timeuuid, primary key
(shard, ts));

select user, ts from user_activity where shard in ('00', '01', ...) order
by ts desc;

Grab each user and ts the first time you see that user.

Use as many shards as you think you need to control row size and spread the

Set ttls to expire user_activity entries when you are no longer interested
in them.


On Fri, Nov 8, 2013 at 6:10 AM, <>wrote:

> Hey guys, I need to retrieve a list of distinct users based on their
> activity datetime. How can I model a table to store that kind of
> information?
> The straightforward decision was this:
> CREATE TABLE user_activity (user text primary key, ts timeuuid);
> but it turned out it is impossible to do a select like this:
> select * from user_activity order by ts;
> as it fails with "ORDER BY is only supported when the partition key is
> restricted by an EQ or an IN".
> How would you model the thing? Just need to have a list of users based on
> their last activity timestamp...
> Thanks!

View raw message