Within a transaction, how do you execute select queries in parallel?

8 views
Skip to first unread message

Jon Wu

unread,
Sep 14, 2017, 6:03:00 PM9/14/17
to Slick / ScalaQuery
Hi,

I'm using Slick 3.1 and am trying to parallelize a few things within a transaction.

I have a for comprehension where I look up some info, then do some inserts and updates. Currently, the inserts and updates happen serially, but I'd love them to all execute at the same time for the best performance.

How can I do this?

val actions: Seq[DBIO[_]] = Seq(insert, update1, update2)
db.run((for {
  // Normally, I'd so something with this
  findResult <- findStuff(...)
  // How can I make all the actions here run in parallel?
  _ <- DBIO.sequence(actions)
} yield ()).transactionally)

Thanks,
Jon
Reply all
Reply to author
Forward
0 new messages