Getting all unique keys

8 views
Skip to first unread message

Avi

unread,
Aug 20, 2017, 2:31:58 AM8/20/17
to DataStax Java Driver for Apache Cassandra User Mailing List
I need to get all unique keys (not the complete primary key, just the partition key) in order to aggregate all the relevant records of that key and apply some calculations on it.

CREATE TABLE my_table (

    id text,

    timestamp bigint,

    value double,

    PRIMARY KEY (id, timestamp) )
I know that to query like this 
SELECT DISTINCT id FROM my_table 
is not very efficient but how about the approach presented here sending queries in parallel and using the token 
SELECT DISTINCT id FROM my_table WHERE token(id) >= -9204925292781066255 AND token(id) <= -9223372036854775808; 
or I can just maintain another table with the unique keys 
CREATE TABLE id_only ( id text,

    PRIMARY KEY (id) )
but I tend not to since it is error prone and will enforce other procedures to maintain data integrity between those two tables .
any ideas ?
Thanks 
Avi
Reply all
Reply to author
Forward
0 new messages