title: Cassandra - poor performance with batch insert in single-node with single-table
body: <h2>The context</h2>
  
  <p>I have just one Cassandra node, installed locally on my PC with Windows 10 (Core i5, 16GB ram, SSD drive).</p>
  
  <p>I created a table like this:</p>
  
  <pre><code>CREATE KEYSPACE covid19 WITH replication = {
      'class':              'SimpleStrategy',
      'replication_factor': '1'
  };
  
  
  CREATE TABLE covid19.cases (
      pesel       text,
      test_date   date,
      result      boolean,
      PRIMARY KEY ((pesel), test_date)
  )
  WITH CLUSTERING ORDER BY (test_date DESC);
  </code></pre>
  
  <p>The <code>pesel</code> is unique, 10-digits id of a person.</p>
  
  <p>Then I generated 10 000 rows of sample data, that looks like this:</p>
  
  <pre><code>INSERT INTO cases (pesel, test_date, result) VALUES ('0000000001', '2020-03-10', true);
  INSERT INTO cases (pesel, test_date, result) VALUES ('0000000002', '2020-03-10', false);
  INSERT INTO cases (pesel, test_date, result) VALUES ('0000000003', '2020-03-10', false);
  INSERT INTO cases (pesel, test_date, result) VALUES ('0000000004', '2020-03-12', false);
  INSERT INTO cases (pesel, test_date, result) VALUES ('0000000005', '2020-03-12', false);
  INSERT INTO cases (pesel, test_date, result) VALUES ('0000000006', '2020-03-12', false);
  ...
  </code></pre>
  
  <p>Finally, I loaded the data using cqlsh: <code>source 'cases.cql';</code></p>
  
  <h2>Problem 1</h2>
  
  <p>To load 10 000 rows it takes 51 seconds. Is that normal?</p>
  
  <p>I was expecting inserts to Cassandra to be ultra fast, while this pretty much comparable with SQLite <strong>without transaction</strong> (59s). If I wrap inserts with <code>BEGIN</code> &amp; <code>COMMIT</code> in SQLite, this takes less than a second. This brings us to another problem...</p>
  
  <h2>Problem 2</h2>
  
  <p>Batch inserting. Slow batch inserting. To single partition, on single node.</p>
  
  <p>I wrapped inserts with <code>BEGIN BATCH</code> and <code>APPLY BATCH;</code>. After that, the <code>source</code> was taking so long, I stopped measuring after passing 4 minutes mark.</p>
  
  <p>Yes, I am aware of wrong usage of batch inserts. As far as I understood, it is an anti-pattern to use batch insert if it would require inserts to different partitions, which makes sense. This is not the case here.</p>
  
  <p>Why is batch inserting so slow on single node (thus single partition)?</p>
  
  <p>What am I missing here?</p>