This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-03
Channels
- # announcements (5)
- # aws (3)
- # babashka (52)
- # babashka-sci-dev (23)
- # beginners (51)
- # calva (191)
- # clj-commons (18)
- # clj-kondo (11)
- # cljdoc (39)
- # cljsrn (3)
- # clojure (24)
- # clojure-czech (3)
- # clojure-dev (2)
- # clojure-europe (15)
- # clojuredesign-podcast (2)
- # clojurescript (8)
- # conjure (2)
- # core-typed (151)
- # cursive (15)
- # data-science (3)
- # datalevin (4)
- # datomic (8)
- # figwheel-main (21)
- # fulcro (37)
- # gratitude (3)
- # honeysql (1)
- # hyperfiddle (2)
- # introduce-yourself (1)
- # malli (3)
- # membrane (54)
- # off-topic (21)
- # other-languages (4)
- # portal (18)
- # re-frame (12)
- # reagent (7)
- # releases (2)
- # sci (64)
- # scittle (1)
- # spacemacs (14)
- # sql (2)
- # vim (4)
- # xtdb (6)
Hi guys! A performance related question here.. This query takes 7-9 seconds to finish executing. It's doing a simple SQL-like join on a dataset that is 11,000 lines big. We're pulling the relevant attributes of each entity (plus the rest of attributes that were cut from the image). Is 7-9 seconds normal for a query like that?
Hard to give an answer without knowing anything about the infrastructure. What is datomic running on? 11000 lines should almost be able to fit in memory.
did you add an index to both the id and the belongs_to attributes? I guess another thing to do is to build it back up from the simplest possible query to see which part is taking all the time.
Also, do you actually need the first join? You don't seem to be using ?data_id
anywhere. If every ?sfd
has a :strive_form_data/id
attribute, you can simplify to just matching for:
[?sfdaa :strive_form_data_additional_answers/belongs_to ?sfd]
^ And if the above is true, you could simplify it to just fetch directly via the index:
(->> (d/datoms :avet :strive_form_data_additional_answers/belongs_to)
(map pull-many ,,,))
Also, you can consider if you need two pulls, since one is just a nested data of the other.
Remember that Datomic does not have a query optimizer, so in general when queries run slow make sure the correct indices are in place AND the order of where clauses reduces the number of matches in the working set. (e.g. are there fewer :strive_form_data/id
or :strive_form_data_additional_answers/belongs_to
datoms? perhaps re-ordering the clauses would help? etc.)