我正在尝试使用 SORM 在大表上执行简单的计数操作。这工作速度莫名其妙。代码:
case class Tests (datetime: DateTime, value:Double, second:Double)
object DB extends Instance (
entities = Set() +
Entity[Tests](),
url = "jdbc:h2:~/test",
user = "sa",
password = "",
poolSize = 10
)
object TestSORM {
def main(args: Array[String]) {
println("Start at " + DB.now())
println(" DB.query[Tests].count() = " + DB.query[Tests].count())
println("Finish at " + DB.now())
DB.close()
}
}
结果:
Start at 2013-01-28T22:36:05.281+04:00
DB.query[Tests].count() = 3390132
Finish at = 2013-01-28T22:38:39.655+04:00
花了两分半钟!在 H2 控制台中,“从测试中选择计数(*)”在一个滴答声中起作用。我的错误是什么?我可以通过它执行sql查询吗?
提前致谢!