This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-17
Channels
- # announcements (6)
- # babashka-sci-dev (6)
- # beginners (99)
- # biff (3)
- # cider (4)
- # clerk (44)
- # clj-kondo (2)
- # clojure (65)
- # clojure-europe (57)
- # clojure-germany (5)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-spec (19)
- # clojure-uk (3)
- # clojurescript (8)
- # conjure (3)
- # cursive (21)
- # datahike (19)
- # datomic (1)
- # events (7)
- # fulcro (14)
- # graalvm (3)
- # gratitude (1)
- # guix (5)
- # honeysql (1)
- # humbleui (19)
- # hyperfiddle (39)
- # lsp (4)
- # malli (7)
- # music (1)
- # off-topic (33)
- # pathom (65)
- # re-frame (9)
- # reagent (3)
- # reitit (6)
- # releases (1)
- # sql (15)
- # tools-build (7)
- # vim (5)
- # xtdb (16)
@seancorfield to what extent have you spent time optimizing jdbc.next in terms of speed. Reason I’m asking is if the answer is “a lot” I won’t spend any time spelunking, but if the answer is “not at all” I’d suspect there could be some quick wins, and I’d be interested in looking into it.
Early on, there was a lot of back and forth between myself and @U055NJ5CC about how to get the most performance out of it -- he's a real "performance nut" so that was very valuable.
You would need to use a custom builder based on a record, to improve on basic hash map builder performance -- there's an example in the test suite.
In general, I'm always fairly resistant to adding new options/features for some edge case if it would introduce a performance overhead for "all users". It's fine if something can be done in a way that only users of a particular feature feel the performance pain of that feature.
All that said, I haven't spent much time recently looking at performance optimizations so if you want to spend time on that, feel free. Just remember: no breaking changes 😉
• jdbc-next is a great and feature-rich library, we use it in all the projects • I believe there would be some small performance wins still available, but if one needs brutal performance, much thinner wrapper on top of java should be created • some perf numbers from 4y back in the 🐷 repo comparing java & clojure options: https://github.com/metosin/porsas • in the (silly) Techempower Bencmarks, my old clojure-entry seems to be still https://www.techempower.com/benchmarks/#section=data-r21&test=db on single query. It’s running on really old version of libs, I think it would be reasonable to get into top 5 with small rewrite. no ambitions for doing that
In other fun stuff today, I mada a change from (merge {.,} some-map-from-jdbc-next)
to (assoc some-map-from-jdbc-next …)
and suddenly tests b0rked because nippy
was unable to serialize something something.
Turns out that jdbc.next adds metadata to the maps it returns so they’re navable.
Someone reported this as a bug on next.jdbc
and I told them to report it as a bug on nippy
instead 🙂
Or just strip metadata from data before serializing it.
(defn post-read*
[entity {:keys [prop->column-type-hint transform-keys entity-type post-read-please-don't-use]
:or {post-read-please-don't-use identity}
:as repo-config}]
(-> (with-meta entity {}) ;; next.jdbc returns results with metadata which makes
;; nippy fritz because it doesn't know how to seralize it
(rename-keys transform-keys)
(postgres/coerce postgres/read-coerce prop->column-type-hint)
post-read-please-don't-use
(core/add-transient :entity-type entity-type)))
post-read-please-don't-use
-- what an awesome symbol name!
post-read-please-don't-use-unless-you-really-have-to
🙂
For anyone using next.jdbc.connection/component
, the develop branch (and the latest 1.3.999-SNAPSHOT) now allows for the db-spec
argument to contain :init-fn
, to specify a function that should be called on the newly-created datasource, when start
is called on the returned Component, so you can have automatic customization of the Java object or automatic database initialization etc.