Cassandra time request

I have the following Cassandra table that logs user access to a web page.

create table user_access (
    id timeuuid primary key,
    user text,
    access_time timestamp
);

and I would like to make such a request:
get a list of users who access the page more than 10 times in the last hour.

Can this be done in Kassandra? (I’m kind of stuck with the limited functions of CQL queries)
If not, how can I redo the table for this?

+4
source share
1 answer

Can you do this? Yes. Can you do it efficiently? I'm not sure.

It is unclear what the timeuuid you are using is.

You can reorganize it on

CREATE TABLE user_access (
  user text,
  access_time timestamp,
  PRIMARY KEY (user_id, access_time)
);

SELECT COUNT(*)
FROM user_access
WHERE user_id = '101'
  AND access_time > 'current unix timestamp - 3600'
  AND access_time < 'current unix timestamp';

. , .

, .

, cql . , , .

+3

All Articles