This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-29
Channels
- # aleph (4)
- # architecture (12)
- # bangalore-clj (1)
- # beginners (87)
- # boot (3)
- # cider (19)
- # cljs-dev (84)
- # clojars (10)
- # clojure (76)
- # clojure-italy (7)
- # clojure-nl (19)
- # clojure-russia (10)
- # clojure-spec (9)
- # clojure-uk (55)
- # clojurescript (64)
- # core-async (7)
- # core-typed (4)
- # cursive (7)
- # data-science (2)
- # datomic (8)
- # devcards (6)
- # docs (1)
- # duct (5)
- # fulcro (117)
- # graphql (1)
- # instaparse (1)
- # leiningen (13)
- # lumo (103)
- # nyc (3)
- # off-topic (54)
- # om (9)
- # onyx (1)
- # pedestal (6)
- # planck (3)
- # portkey (7)
- # re-frame (26)
- # reagent (20)
- # ring-swagger (14)
- # shadow-cljs (164)
- # sql (11)
- # tools-deps (25)
- # yada (1)
Is it possible to lazily iterate over a big result set, invoking a function on each row?
the answer will differ depending on which layer you want to do this in; in postgres you can do this with cursors
So, I am using postgres. But the function I'd want to invoke on each row would be a clojure function. Was hoping there might be a way to do this using clojure.java.jdbc
@cddr this may help: https://stackoverflow.com/questions/39765943/clojure-java-jdbc-lazy-query
See the docs under Processing a result set lazily
here http://clojure-doc.org/articles/ecosystem/java_jdbc/using_sql.html
@cddr Pay attention specifically to the caveats around database-specific tweaks you may need to make the result set processing fully lazy -- auto-commit on opening connections, result set cursors etc.
@cddr The reducible-query
machinery is relatively new, but is the recommended way to deal with processing large result sets. If you hit any issues with it, let me know. We use it in production at work, but not extensively yet.
I've added another answer there and gone through a few other SO posts relating to clojure.java.jdbc
. Clearly, this is an ongoing project to try to keep answers up-to-date and accurate 😞