Hi everyone, I found the solution and it has nothing to do with my ramblings above.
It turns out that when I do (.executeQuery stmt), the MySQL JDBC driver fetches the entire resultset from the server at once. Here is how to make it lazy also on the JDBC side: (let [conn (datasource/connection datasource/cdr-c4) stmt (.prepareStatement conn (format "SELECT SUBSTRING(a,5) AS a, SUBSTRING(b,3) AS b, SUBSTRING(st,1,14) AS st, duration/1000 AS duration FROM `call` WHERE st LIKE '%s%%' ORDER BY st" st-prefix) java.sql.ResultSet/TYPE_FORWARD_ONLY java.sql.ResultSet/CONCUR_READ_ONLY)] (.setFetchSize stmt Integer/MIN_VALUE) ... With this change, everything works as expected. Details about why this works: http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-implementation-notes.html (scroll down to the section on "ResultSet") (Note, that this is a MySQL-only solution, other JDBC drivers may require different tricks.) P.s. I still don't understand though why the 'calls' argument to the store-calls function is not a held reference to the head of the lazy seq... -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en