【发布时间】:2016-03-29 06:21:29
【问题描述】:
我正在使用 slick 3.0.0-M1 和 "com.zaxxer" % "HikariCP" % "2.4.3"
Slick 正在为每个错误的查询(由日志记录指示)准备一个语句:
"Preparing statement: select * from ..."
我的配置告诉 Slick / Hikari 缓存准备好的语句:
myDB {
url = "jdbc:mysql://...
user = ...
...
connectionPool = HikariCP
queueSize = 50000
maxConnections = 50
properties.cachePrepStmts = true
properties.prepStmtCacheSize = 20000
properties.prepStmtCacheSqlLimit = 100000
}
日志似乎表明这些属性已被读取:
configuration:
...
dataSourceName..................
dataSourceClassName.............
dataSourceProperties............
{password=<masked>,
prepStmtCacheSqlLimit=100000,
cachePrepStmts=true,
prepStmtCacheSize=20000}
maximumPoolSize.................50
poolName..........................
db 对象被实例化并用于测试:
val db = Database.forConfig("", config.getConfig("myDB"))
val qTemplate = StaticQuery[(Int), MyRow] + "select * from table_name where num=?"
db.withSession{ implicit session =>
(0 until 100).foreach{ case i =>
qTemplate(2).foreach(println)
}
}
对于 qTemplate(2) 的每次调用,slick 都会记录 'Preparing Statement...' 为什么模板没有被缓存?
【问题讨论】:
标签: mysql scala slick hikaricp