title: Why is SQLite so slow (~2 q/s) on a specific machine?
body: <p>On one of my servers (i7 Ivy Core, 32 GB RAM, Debian 6 @ 64bit, PHP 5.4.10) I experience extremely slow inserts with SQLite. The following test program reports just <strong>2.2 inserts/second</strong> (14 seconds for inserting 30 rows).</p>
  
  <pre><code>unlink("test.db");
  
  $db = new PDO('sqlite:test.db');
  
  $db-&gt;exec("CREATE TABLE test (dummy INT)");
  
  $count = 30;
  
  $t = microtime(true);
  for ($i=0; $i&lt;$count; $i++) {
    $db-&gt;exec("INSERT INTO test VALUES ($i)")
     or die("SQLite error: ".$db-&gt;errorInfo()[2]."\n");
  }
  $elapsed = microtime(true)-$t;
  echo sprintf("%d inserts in %.3f secs (%.1f q/s)\n", 
    $count, $elapsed, $count/$elapsed);
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>$ time php test.php
  30 inserts in 13.911 secs (2.2 q/s)
  
  real    0m14.634s
  user    0m0.004s
  sys     0m0.016s
  </code></pre>
  
  <p>I know that I can accelerate this by wrapping <code>BEGIN</code>/<code>END</code> around the insert statements (which gives me 200000 q/s) but even without a transaction this should be <em>much</em> faster. On other (older) machines (same PHP version) I reach 300+ queries/sec without explicit transactions.</p>
  
  <p>What could be the cause for this? Do I have to tune Sqlite or the O/S?</p>