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