cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nate McCall <n...@thelastpickle.com>
Subject Re: CQL 3 and wide rows
Date Tue, 20 May 2014 15:16:33 GMT
Something like this might work:


cqlsh:my_keyspace> CREATE TABLE my_widerow (
                 ...   id text,
                 ...   my_col timeuuid,
                 ...   PRIMARY KEY (id, my_col)
                 ... ) WITH caching='KEYS_ONLY' AND
                 ...   compaction={'class': 'LeveledCompactionStrategy'};
cqlsh:my_keyspace> insert into my_widerow (id, my_col) values
('some_key_1',now());
cqlsh:my_keyspace> insert into my_widerow (id, my_col) values
('some_key_1',now());
cqlsh:my_keyspace> insert into my_widerow (id, my_col) values
('some_key_1',now());
cqlsh:my_keyspace> insert into my_widerow (id, my_col) values
('some_key_1',now());
cqlsh:my_keyspace> insert into my_widerow (id, my_col) values
('some_key_1',now());
cqlsh:my_keyspace> insert into my_widerow (id, my_col) values
('some_key_1',now());
cqlsh:my_keyspace> insert into my_widerow (id, my_col) values
('some_key_1',now());
cqlsh:my_keyspace> insert into my_widerow (id, my_col) values
('some_key_1',now());
cqlsh:my_keyspace> insert into my_widerow (id, my_col) values
('some_key_1',now());
cqlsh:my_keyspace> insert into my_widerow (id, my_col) values
('some_key_1',now());
cqlsh:my_keyspace> select * from my_widerow;

 id         | my_col
------------+--------------------------------------
 some_key_1 | 7266d240-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 73ba0630-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 74404d30-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 74defe30-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 75569f30-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 75bf9a30-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 76227ab0-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 76cfd1b0-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 777364b0-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 7aa061b0-e030-11e3-a50d-8b2f9bfbfa10

cqlsh:my_keyspace> select * from my_widerow where id = 'some_key_1' and
my_col > 73ba0630-e030-11e3-a50d-8b2f9bfbfa10;

 id         | my_col
------------+--------------------------------------
 some_key_1 | 74404d30-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 74defe30-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 75569f30-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 75bf9a30-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 76227ab0-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 76cfd1b0-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 777364b0-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 7aa061b0-e030-11e3-a50d-8b2f9bfbfa10

cqlsh:my_keyspace> select * from my_widerow where id = 'some_key_1' and
my_col > 73ba0630-e030-11e3-a50d-8b2f9bfbfa10 and my_col <
76227ab0-e030-11e3-a50d-8b2f9bfbfa10;

 id         | my_col
------------+--------------------------------------
 some_key_1 | 74404d30-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 74defe30-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 75569f30-e030-11e3-a50d-8b2f9bfbfa10
 some_key_1 | 75bf9a30-e030-11e3-a50d-8b2f9bfbfa10



These queries would all work fine from the DS Java Driver. Note that only
the cells that are needed are pulled into memory:


./bin/nodetool cfstats my_keyspace my_widerow
   ...
   Column Family: my_widerow
   ...
   Average live cells per slice (last five minutes): 6.0
   ...


This shows that we are slicing across 6 rows on average for the last couple
of select statements.

Hope that helps.



-- 
-----------------
Nate McCall
Austin, TX
@zznate

Co-Founder & Sr. Technical Consultant
Apache Cassandra Consulting
http://www.thelastpickle.com

Mime
View raw message