score:0

My first guess is that you might still be using the default in memory database. Can you check and make sure your conf/application.conf is not using jdbc:h2:mem:play? If so, all of your entries would be filling up your memory.

Also, each statement that you make opens a statement object that doesn't get closed until the end of the withConnection block. Since you have a million of them sitting in memory, that can build up. See http://www.playframework.org/documentation/2.0/ScalaDatabase

You could try populating the DB outside of your query operation. I would experiment with doing 1000 batches of 1000 and seeing if that identifies your problem.

score:0

I think that your problem lies here:

val tuples: List[(Long, String)] = {

  val sqlQuery = SQL("select id, title from article order by id;")

  sqlQuery()(connection).map(row =>
    row[Long]("id") -> row[String]("title")).toList
}

You are populating a map with all the rows form the database so you are fillng a Scala/Java data stucture with 1M of rows.

Do you really need one million of rows all at once? Or do you need them in paginated way (i.e the first 20 the second 20, etc,etc).

It's not a play problem, you will encounter the same problem even with java and a single plain jdbc test. Tell us the real usage of tuples and we can provide some suggestions.


Related Query

More Query from same tag