First, see https://jdbc.postgresql.org/documentation/83/query.html#query-with-cursor.
Solved it like this.
(jdbc/with-db-transaction [tx connection]
(jdbc/query tx
[(jdbc/prepare-statement (:connection tx)
"select * from mytable"
{:fetch-size 10})]
{:result-set-fn (fn [result-set] ...)}))
where :result-set-fn
is a function that consumes the lazy result set.
with-db-transaction
takes care of autoCommit
set to false
.
:fetch-size
is not passed from query
so you have to make a prepare-statement
yourself.