Re: Data model for boolean attributes

2014-03-22 Thread James Rothering
Hi Duy: The compound partition key seems perfect, but you say that pagination isn't possible with it: why is that? Regards, James On Sat, Mar 22, 2014 at 10:40 AM, DuyHai Doan wrote: > Ben > > > > When you say beware of the cardinality, do you think that the > cardinality is too low in this

Re: Data model for boolean attributes

2014-03-22 Thread DuyHai Doan
Ben > When you say beware of the cardinality, do you think that the cardinality is too low in this instance? Secondary indexes in C* are distributed across all the nodes containing actual data so somehow it helps avoiding hot spots. However, since there are only 2 values for your boolean flag, e

Re: Data model for boolean attributes

2014-03-21 Thread Ben Hood
Hey Duy Hai, On Fri, Mar 21, 2014 at 7:34 PM, DuyHai Doan wrote: > Your previous "select * from x where flag = true;" translate into: > > SELECT * FROM x WHERE id=... AND flag = true > > Of course, you'll need to provide the id in any case. This is an interesting option, though this app needs

Re: Data model for boolean attributes

2014-03-21 Thread Ben Hood
On Sat, Mar 22, 2014 at 3:32 AM, Ben Hood <0x6e6...@gmail.com> wrote: > Also a very good point. The main query paths the app needs to support are: > > select * from x where flag=true and id = ? and timestamp >= ? and timestamp > <= ? > select * from x where flag=false and id = ? and timestamp >= ?

Re: Data model for boolean attributes

2014-03-21 Thread Ben Hood
On Sat, Mar 22, 2014 at 1:31 AM, Laing, Michael wrote: > Whoops now there are only 2 partition keys! Not good if you have any > reasonable number of rows... Yes, this column family will have a large number of rows. > I monitor partition sizes and shard enough to keep them reasonable in this > so

Re: Data model for boolean attributes

2014-03-21 Thread Laing, Michael
Of course what you really want is this: create table x( id text, timestamp timeuuid, flag boolean, // other fields primary key (flag, id, timestamp) ) Whoops now there are only 2 partition keys! Not good if you have any reasonable number of rows... Faced with a situation like this (alt

Re: Data model for boolean attributes

2014-03-21 Thread DuyHai Doan
Hello Ben Try the following alternative with composite partition key to encode the dual states of the boolean: create table x( id text, flag boolean, timestamp timeuuid, // other fields primary key (*(id,flag)* timestamp) ) Your previous "select * from x where flag = true;" transla

Data model for boolean attributes

2014-03-21 Thread Ben Hood
Hi, I was wondering what the best way is to lay column families out so that you can to query by a boolean attribute. For example: create table x( id text, timestamp timeuuid, flag boolean, // other fields primary key (id, timestamp) ) So that you can query select * from x where flag