I just found out that the Postgres Java JDBC driver does not really support the SCROLL_SENSITIVE
/SCROLL_INSENSITIVE
modes using streaming, but instead simulates those modes by loading the full result set into client memory all at once. For queries with a big result set, that can lead to an unexpectedly huge memory usage, especially in a language like Java with little support for unboxed values. When using FORWARD_ONLY
mode, the driver streams the results as expected.
(details; From my understanding this is a limitation of the Postgres wire protocol, though the driver could maybe in theory work around that by converting queries into explicit cursors.)
To prevent such surprises in the future, I'm wondering how wide spread such behavior is and which other common JDBC drivers do not implement real scrolling where that would be expected, so I know to watch out for that if I happen to use one of those drivers. Which other common JDBC drivers do not support all of the scrolling modes in a streaming fashion?