Created
August 26, 2014 16:48
Revisions
-
thinkerbot created this gist
Aug 26, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ DROP KEYSPACE IF EXISTS example; CREATE KEYSPACE example WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }; USE example; DROP TABLE IF EXISTS xyz; create table xyz ( xpart int, x int, z int, y int, PRIMARY KEY (xpart, x, z) ); insert into xyz (xpart, z, x, y) values (0, 1, 1, 1); insert into xyz (xpart, z, x, y) values (0, 1, 2, 2); insert into xyz (xpart, z, x, y) values (0, 2, 2, 1); insert into xyz (xpart, z, x, y) values (0, 2, 3, 2); insert into xyz (xpart, z, x, y) values (0, 3, 3, 1); insert into xyz (xpart, z, x, y) values (0, 3, 4, 2); -- TRACING ON; -- Queries using part key can be EQ/IN -- Queries on cluster key(s) may be chained as long as the preceding is EQ -- The final cluster key may use GT,LT,GTE,LTE -- -- Can sort on the SECOND column, but that means you would have to always -- be able to specify the second column as EQ to get to the third column. select * from xyz; select * from xyz where xpart = 0; select * from xyz where xpart = 0 and x = 2; select * from xyz where xpart = 0 and x >= 2 and x < 4; select * from xyz where xpart = 0 and x = 3 and z > 2; select * from xyz where xpart IN (0,1) and x >= 2 and x < 4;