According to the release notes for the MySQL JDBC driver, it should stream results if and only if using a connection with concurrency read-only, forward-only results, and a fetch-size of exactly Integer/MIN_VALUE.
However, when I attempt to generate exactly these conditions (against [mysql/mysql-connector-java "5.1.21"]
), my SQL query still runs forever (or, rather, until it exhausts the JVM's memory and goes boom).
(let [query (query-only (fetch-all big-table))]
(clojure.java.jdbc/with-connection (get-connection (:db query))
(clojure.java.jdbc/with-query-results rows
(into [{:fetch-size Integer/MIN_VALUE
:concurrency :read-only
:result-type :forward-only} (:sql-str query)]
(:params query))
(throw (Exception. (str "retrieved a row: " (pr-str (first rows)))))))))