cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chandra Sekar KR <chandraseka...@hotmail.com>
Subject Range scans
Date Thu, 19 Nov 2015 09:46:23 GMT
Hi,


I would like to run a range scan on timestamp column b with secondary indexes without passing
the partition key. I'm aware that Cassandra does not support range scans on secondary indexes
unless one more column (primary/secondary index) clause with an = operator is supplied.

CREATE TABLE test (
    a timeuuid PRIMARY KEY,
    b timestamp,
    c varint
);
CREATE INDEX indx_b ON test (b);

INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000000);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000001);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000002);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000003);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000004);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000005);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000006);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000007);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000008);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000009);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000010);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000011);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000012);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000013);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000014);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000015);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000016);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000017);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000018);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000019);
INSERT INTO TEST(a,b,c) VALUES (now(), unixTimestampOf(now()), 1000020);


Also, is there any alternate way of running range scans on column a using TOKEN function,
similar to below. I tried running the same, but was getting unexpected results.

SELECT * FROM test
  WHERE TOKEN(a) >= TOKEN(3b84a5b0-8e8d-11e5-b494-c9d29cfa4efd)
  AND TOKEN(a) <= TOKEN(3b8c94f0-8e8d-11e5-b494-c9d29cfa4efd);


Regards, Chandra Sekar KR

Mime
View raw message