title: Cassandra time series data model with counter column
body: <p>I am trying to model a cassandra data set for a time series where I capture the sum of bytes over a minute for a given user, using a counter column.  Using CQL3 I have this create table syntax:</p>
  
  <pre><code>CREATE TABLE minute_usr (
  min varchar,
  usr varchar,
  bytes counter,
  PRIMARY KEY (min, usr)
  )
  </code></pre>
  
  <p>I am able to update the column using this query:</p>
  
  <pre><code>UPDATE minute_usr SET bytes = bytes + 200 WHERE usr = 'testuser' AND min = '1369448220';
  </code></pre>
  
  <p>however I would like to now get back the value of 'bytes' for a range of minutes where usr = 'username':</p>
  
  <pre><code>select min, bytes from minute_usr WHERE usr = 'testuser' AND min &gt;= '1369448160' and min &lt;= '1369448220';
  </code></pre>
  
  <p>and I am getting back the error:</p>
  
  <blockquote>
    <p>Bad Request: Only EQ and IN relation are supported on the partition key for random partitioners (unless you use the token()
    function)</p>
  </blockquote>
  
  <p>I was under the assumption that CQL was creating a composite key out of 'min' and 'usr' when creating the table allowing me to get a range of composite keys.  The cli is actually telling me that the key is actually just the value of 'min':</p>
  
  <pre><code>[default@data_use] list minute_usr; 
  Using default limit of 100 
  Using default column limit of 100  
  RowKey: 1369448220
  =&gt; (column=testuser:, value=, timestamp=1371066133370000)
  =&gt; (counter=testuser:bytes, value=1400)
  
   RowKey: 1369448160
  =&gt; (column=testuser:, value=, timestamp=1371066138506000)
  =&gt; (counter=testuser:bytes, value=1600)
  </code></pre>
  
  <p>Am I simply limited to doing an individual query for each timestamp / username combination with this data model?</p>
  
  <p>I have also tried modeling the data with the username as the first part of the key, which allows me to do range queries </p>
  
  <pre><code>CREATE TABLE usr_minute (
  min varchar,
  usr varchar,
  bytes counter,
  PRIMARY KEY (usr, min)
  )
  </code></pre>
  
  <p>And then I could do a range query on the column names for minutes like so:</p>
  
  <pre><code>`select bytes from usr_minute WHERE usr = 'testuser' AND min &gt;= '1369448160' and min &lt;= '1369448220';`
  </code></pre>
  
  <p>however I know that these values are now being stored in a single row which has limitations in terms of number of columns that can be stored, and I would like to let this data set grow forever.</p>
  
  <p>Not sure how to proceed.</p>