This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-22
Channels
- # announcements (2)
- # architecture (33)
- # babashka (4)
- # beginners (445)
- # bristol-clojurians (10)
- # calva (23)
- # cider (43)
- # clj-kondo (36)
- # cljs-dev (13)
- # cljsrn (20)
- # clojure (136)
- # clojure-argentina (8)
- # clojure-dev (1)
- # clojure-europe (18)
- # clojure-germany (1)
- # clojure-italy (5)
- # clojure-nl (45)
- # clojure-spec (66)
- # clojure-uk (29)
- # clojurescript (69)
- # conjure (157)
- # cursive (2)
- # datomic (216)
- # emacs (10)
- # exercism (4)
- # figwheel-main (8)
- # fulcro (30)
- # graphql (21)
- # hoplon (5)
- # kaocha (7)
- # leiningen (3)
- # luminus (4)
- # music (1)
- # off-topic (24)
- # pathom (10)
- # re-frame (19)
- # reagent (11)
- # reitit (16)
- # remote-jobs (1)
- # ring-swagger (5)
- # rum (7)
- # shadow-cljs (125)
- # spacemacs (8)
- # sql (9)
- # tools-deps (12)
What would be the most efficient read-only options for Connection
and PreparedStatement
?
DB changes won't happen during those SELECTs.
DB pools are not used but connections and statements are re-used many times, closed only at the end.
I did some research and came up with this...
get-connection
opts:
{:read-only true
:auto-commit false}
prepare
opts:
{:concurrency :read-only
:cursors :close
:result-type :forward-only}
I was thinking of :fetch-size
but https://github.com/seancorfield/next-jdbc/blob/master/doc/all-the-options.md#statements--prepared-statements mentiones "zero or a negative value [...] trigger streaming of result sets"...
Not sure what that streaming is... I don't really need laziness here, the whole result is needed, i.e. I'm using execute
, not plan
.How :fetch-size
(or, in fact, any of those options) interact with performance and/or streaming is very DB-specific.
I probably ought to update the docs about fetch size in particular since for PostgreSQL at least you need fetch size set to something positive when you're streaming result sets.
I need most universal read-only opts as defaults since it will be used for different rdbms... Guess I should avoid setting the :fetch-size
.
It seems that MySQL uses streaming only https://stackoverflow.com/a/20900045
Yeah, it's really hard to configure things in a way that will work the same universally 😞
Ah, I see if you set useCursorFetch
as a connection option on MySQL you can use fetch size just like other DBs. Oh great. And then of course if you want multi-row inserts to work as single batch operations, you need a custom option ... which is different for PostgreSQL and for MySQL 🙂
(argh! That option enables server-side cursors in a temporary table 👀 Good grief... whoever thought that was a good idea?)
I'm looking for a read-only minimum 🙂 Users will be able to change it... But not all users know / understand these JDBC options (me neither). Will test performance on most popular RDBMs to find out.