compiled delete prepared statement is prepared once per call (slick 3.2.0)

26 views
Skip to first unread message

Kostas kougios

unread,
Apr 24, 2017, 5:41:24 AM4/24/17
to Slick / ScalaQuery
Hi,

I am using a compiled delete prepared statement like:

val CompiledDel = Compiled((id: Rep[Int]) => tables.Test.filter(_.id === id))

val ops = for (i <- 1 to 100) yield {
CompiledDel(i).delete
}

DBIO.sequence(ops)
.transactionally
.withTransactionIsolation(isolation)


I would expect this to compile once to a prepared statement and then execute that prepared statement 100 times but I enable debug log and I get the statement prepared 100 times:

2017-04-24_10:37:15.475 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.statement - Preparing statement: delete from "test" where "test"."id" = ?
2017-04-24_10:37:15.476 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - /-----\
2017-04-24_10:37:15.476 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | 1   |
2017-04-24_10:37:15.476 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | Int |
2017-04-24_10:37:15.476 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - |-----|
2017-04-24_10:37:15.476 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | 97  |
2017-04-24_10:37:15.476 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - \-----/
2017-04-24_10:37:15.490 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.benchmark - Execution of prepared update took 14ms
2017-04-24_10:37:15.490 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.statement - Preparing statement: delete from "test" where "test"."id" = ?
2017-04-24_10:37:15.491 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - /-----\
2017-04-24_10:37:15.491 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | 1   |
2017-04-24_10:37:15.491 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | Int |
2017-04-24_10:37:15.491 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - |-----|
2017-04-24_10:37:15.491 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | 98  |
2017-04-24_10:37:15.491 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - \-----/
2017-04-24_10:37:15.505 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.benchmark - Execution of prepared update took 13ms
2017-04-24_10:37:15.505 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.statement - Preparing statement: delete from "test" where "test"."id" = ?
2017-04-24_10:37:15.505 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - /-----\
2017-04-24_10:37:15.505 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | 1   |
2017-04-24_10:37:15.505 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | Int |
2017-04-24_10:37:15.505 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - |-----|
2017-04-24_10:37:15.505 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | 99  |
2017-04-24_10:37:15.505 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - \-----/
2017-04-24_10:37:15.519 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.benchmark - Execution of prepared update took 13ms
2017-04-24_10:37:15.519 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.statement - Preparing statement: delete from "test" where "test"."id" = ?
2017-04-24_10:37:15.519 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - /-----\
2017-04-24_10:37:15.519 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | 1   |
2017-04-24_10:37:15.520 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | Int |
2017-04-24_10:37:15.520 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - |-----|
2017-04-24_10:37:15.520 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - | 100 |
2017-04-24_10:37:15.520 [pool-1-thread-3] DEBUG slick.jdbc.JdbcBackend.parameter - \-----/

Any idea why so?

Thanks
Reply all
Reply to author
Forward
0 new messages