Reputation: 13706
My scala code running a select performs an order of magnitude slower than issuing the same query on MySQL Workbench. The time between my debug prints connection made
and query returned
is exceptionally long compared to the same query in MySQL Workbench, all other steps are fast. Of course I am using the same database user in both cases.
import java.sql.{Connection,DriverManager,ResultSet}
object JavaSQL extends App {
val driver = "com.mysql.jdbc.Driver"
val url = ..
val user = ..
val password = ..
println("loading driver")
Class.forName(driver) // loads the driver
println("driver loaded")
val connection = DriverManager.getConnection(url, user, password)
println("connection made")
val rs: ResultSet = connection.createStatement.executeQuery("SELECT * from Foo")
println("query returned")
connection.close
}
build.sbt:
lazy val project = (project in file("."))
.settings(
scalaVersion := "2.11.7",
libraryDependencies ++= Seq("mysql" % "mysql-connector-java" % "5.1.38")
)
What should I basically do to get it at par? It is as slow as running the same query in mysql's command-line. Workbench must be using some special flags.
I've used JDBC/SQL abstractions for a while and now returning to java.sql so please be gentle..
Upvotes: 2
Views: 721