Skip to content

Instantly share code, notes, and snippets.

@brianwawok
Created November 21, 2015 15:58
Show Gist options
  • Save brianwawok/527e223e96203d10c951 to your computer and use it in GitHub Desktop.
Save brianwawok/527e223e96203d10c951 to your computer and use it in GitHub Desktop.
create table website_hits(
full_url TEXT,
hit_date TIMESTAMP,
website_hit_id UUID,
PRIMARY KEY(full_url, hit_date, website_hit_id )
) WITH CLUSTERING ORDER BY (hit_date DESC);
insert into website_hits(full_url, hit_date, website_hit_id) values('www.foo.com', dateof(now()), uuid());
insert into website_hits(full_url, hit_date, website_hit_id) values('www.bar.com', dateof(now()), uuid());
insert into website_hits(full_url, hit_date, website_hit_id) values('www.bar.com', dateof(now()), uuid());
insert into website_hits(full_url, hit_date, website_hit_id) values('www.foo.com', dateof(now()), uuid());
cqlsh:test> select distinct full_url from website_hits;
full_url
-------------
www.bar.com
www.foo.com
(2 rows)
cqlsh:test> select count(*) from website_hits where full_url = 'www.foo.com';
count
-------
2
(1 rows)
cqlsh:test> select count(*) from website_hits where full_url = 'www.foo.com' and hit_date > '2015-01-01';
count
-------
2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment