[2.2.1-scala] Anorm asBatch performance issue?

67 views
Skip to first unread message

Emre Çelikten

unread,
Dec 25, 2013, 4:16:28 AM12/25/13
to play-fr...@googlegroups.com
Hello everyone,

I noticed this: https://github.com/playframework/playframework/blob/master/framework/src/anorm/src/main/scala/anorm/Anorm.scala#L471

It seems a BatchSql object is created using Nil for "params" parameter. The issue here is that Nil is an empty list and you guys seem to append to the list (which is linear-time) when addBatch is called: https://github.com/playframework/playframework/blob/master/framework/src/anorm/src/main/scala/anorm/Anorm.scala#L354

This makes batch operations quadratic-time.

Emre

Johan Andren

unread,
Dec 28, 2013, 1:34:47 PM12/28/13
to play-fr...@googlegroups.com
Have you profiled and seen that this inefficiency actually is significant when doing batching? I would expect performing the actual batch to be orders of magnitude slower than appending to a list.

Anyways, good find, I think you should file a bug report!
Reply all
Reply to author
Forward
0 new messages