Sean Corfield <[email protected]> writes:
> A new function, reducible-query, has been added that accepts a db-spec
> and a SQL/parameters vector, and returns a “reducible collection”. The
> query doesn’t actually run until you reduce it. At that point, it sets
> up the PreparedStatement, runs the query, and processes the ResultSet
> – by creating an interim “reducible collection” version of that result
> set and delegating your reduce operation to that. The connection is
> automatically closed when reduction completes, either by processing
> the entire result set or by returning a ‘reduced’ value.
How does one force the jdbc driver to return results lazily when using
reducible-query?
Currently I'm using the following code to force postgresql into
streaming mode:
(jdbc/with-db-connection [conn config/db]
(.setAutoCommit (jdbc/db-find-connection conn) false)
(jdbc/query conn
query
{:fetch-size 500
:result-set-fn (fn [coll] (doall (take 2 coll)))}))
(config/db is map describing a postgresql connection, query is an sql
query)
This works as expected.
Trying to to the same with reducible-query with something like:
(into [] (take 2) (jdbc/reducible-query config/db query {:fetch-size 500}))
results in a 'GC overhead limit exceeded' error. The postgresql driver
isn't streaming the results, but instead returns the whole result in one
large response.
I don't have the ability to call .setAutoCommit on the connection in
that case.
I would very much like an easy way to turn on streaming (e.g. by passing
{:use-streaming? true} as an option).
Do you have any plans for that?
Thanks for your work on java.jdbc.
--
Cheers
Ralf
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.