title: Cassandra batch insert by single partition key
body: <p>We are using datastax driver to talk to Cassandra. We have this below column family.</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS "DATA".xxx (
      key text,
      column1 bigint,
      value blob,
      PRIMARY KEY (key, column1)
  ) WITH COMPACT STORAGE AND speculative_retry = 'NONE';
  </code></pre>
  
  <p>I have to do a lot of inserts into this column family. We did a lot of individual async requests as recommended by datastax but we found out that we got better performance using "unlogged batches". Its kind of strange that, using unlogged batches worked better for us, probably because of how small our individual writes were.</p>
  
  <p>Now, I want to follow the recommendation of datastax and do only single-partition inserts using unlogged batches, which means I want to batch all the inserts which belong to a single partition and do a batch insert. </p>
  
  <p>In our cassandra setup, we use <code>Murmur3Partitioner</code>. Is there anyway, I can compute the partition key in my application so that I can batch them by single partition key, to insert in batches?</p>
  
  <p>Also, does number of cassandra nodes have any effect on this? I mean, as we add more nodes in the future, would there be a change in logic to compute partition key?</p>