title: Scala Slick 2.0 and SQlite3 insert speed and PRAGMA
body: <p>This questions is similar to these:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/15778716/sqlite-insert-speed-slows-as-number-of-records-increases-due-to-an-index">SQLite insert speed slows as number of records increases due to an index</a></li>
  <li><a href="https://stackoverflow.com/questions/1711631/how-do-i-improve-the-performance-of-sqlite">Improve INSERT-per-second performance of SQLite?</a></li>
  </ul>
  
  <p>I have to index certain features from the Wikipedia XML dump. The parsing is fast. However, insert is slow.</p>
  
  <p>Switching off indexing doubled the speed.</p>
  
  <p>I batch insert like this:</p>
  
  <pre><code>    articles.grouped(5000)
             .foreach {
                batch: IterableView[(Article, List[Category], List[Link]), Iterable[_]] =&gt;
                  //Save each batch in one transaction
                  database withTransaction {
                   implicit session =&gt;
                     for(i &lt;- batch) {
                       articles += i._1
                       categories ++= i._2
                       links ++= i._3
                     }
  
                 }
              }
  </code></pre>
  
  <p>I read that <code>journal_mode = MEMORY</code> and <code>synchronous = off</code> increase the insert speed. How do I set these with slick? I am using c3p0 as a connection pool and added <code>PRAGMA journal_mode = MEMORY</code> to <code>preferredTestQuery</code>. I don't believe this is the right way to set these options.</p>
  
  <p>Thanks for your help!</p>