prepared statements are prepared multiple times on the same thread and same Connection instance

14 views
Skip to first unread message

Kostas kougios

unread,
Feb 16, 2017, 1:29:44 PM2/16/17
to Slick / ScalaQuery


[debug] 2017-02-16 18:27:52 [pool-1-thread-7] s.j.J.statement - Preparing statement: insert into "tocnode" ("id","identifier","title","type","publication_id","root","local","formulary_id")  values (?,?,?,?,?,?,?,?)
[debug] 2017-02-16 18:27:52 [pool-1-thread-8] s.j.J.benchmark - Execution of prepared update took 11ms
[debug] 2017-02-16 18:27:52 [pool-1-thread-7] s.j.J.benchmark - Execution of prepared update took 11ms
[debug] 2017-02-16 18:27:52 [pool-1-thread-8] s.j.J.statement - Preparing statement: insert into "tocnode" ("id","identifier","title","type","publication_id","root","local","formulary_id")  values (?,?,?,?,?,?,?,?)
[debug] 2017-02-16 18:27:52 [pool-1-thread-7] s.j.J.statement - Preparing statement: insert into "tocnode" ("id","identifier","title","type","publication_id","root","local","formulary_id")  values (?,?,?,?,?,?,?,?)
[debug] 2017-02-16 18:27:52 [pool-1-thread-8] s.j.J.benchmark - Execution of prepared update took 11ms
[debug] 2017-02-16 18:27:52 [pool-1-thread-7] s.j.J.benchmark - Execution of prepared update took 11ms


so I have 1 big transaction, pushing all data to slick. It seems to run these in 2 threads (probably 2 connection instances, debugged the pool and it seems it uses the same Connection instances)

I am using compiled prepared statements:

    private val insertTocNode = Compiled(tables.Tocnode)

Why so? Can it be optimized? The problem is that I am connecting to a remote db and preparing the statenments takes 11ms as you can see from the above logs.

Kostas kougios

unread,
Feb 17, 2017, 3:09:20 AM2/17/17
to Slick / ScalaQuery
Actually i have 2 transactions, so please ignore the 2nd thread. So within 1 transaction that inserts a lot of rows in tocnode table, the prepared statement is prepared multiple times. All occuring within the same thread and using the same Connection - as expected.
Reply all
Reply to author
Forward
0 new messages