Closed AlexITC closed 1 year ago
Try reading using direct ResultSet
(the stage is not accumulating data, just wrapping Result
).
If the result is the same ...
Try reading using direct ResultSet
I'll try and update the ticket later,
the stage is not accumulating data, just wrapping Result
Yes, I figured this out while checking the source, which is why I mentioned that the problem seems to came from jdbc, I don't know if there is a way to prevent this.
Checking the jdbc driver option/workarounds, other do see anything at Anorm level.
After putting sometime into this, I checked the official postgres-jdbc-docs which specify that by default, the whole result set is loaded into memory but there is a simple way to avoid that (setFetchSize
), gladly, SimpleSql
has a method available to set such a value (withFetchSize
) while autoCommit
must be false
. After applying those changes, the stream behaves the way I expected.
Thanks.
Thanks for the feedback.
Are you looking for help?
No.
Anorm Version (2.5.x / etc)
2.6.10
Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)
Ubuntu 20.04 x86_64
JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)
Library Dependencies
Also, postgresql 15.
Expected Behavior
There shouldn't be a huge memory consumption when streaming the result from a huge table.
Actual Behavior
The whole ResultSet seems to be loaded into memory, I have already tried to
throttle
the stream, set a small buffer, still, there is no improvement.Reproducible Test Case
The reproduction example can be executed by scala-cli with
scala-cli AnormAkkaStreamsBroken.scala
, a postgres server needs to be running, the code includes instructions to launch it with docker.Demo:
Screencast from 16-11-22 07:04:27.webm