This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-03
Channels
- # aleph (5)
- # announcements (4)
- # babashka (2)
- # beginners (52)
- # calva (13)
- # cider (60)
- # clj-kondo (91)
- # cljsrn (6)
- # clojure (93)
- # clojure-brasil (2)
- # clojure-dev (37)
- # clojure-europe (5)
- # clojure-italy (7)
- # clojure-nl (8)
- # clojure-norway (1)
- # clojure-sg (1)
- # clojure-spec (115)
- # clojure-uk (31)
- # clojurescript (32)
- # cursive (35)
- # data-science (4)
- # datascript (3)
- # datomic (29)
- # emacs (8)
- # events (1)
- # figwheel (1)
- # funcool (2)
- # graalvm (2)
- # joker (12)
- # kaocha (4)
- # lein-figwheel (1)
- # leiningen (34)
- # malli (7)
- # off-topic (4)
- # overtone (1)
- # parinfer (2)
- # pathom (5)
- # quil (1)
- # re-frame (12)
- # reagent (2)
- # shadow-cljs (7)
- # spacemacs (6)
- # sql (8)
- # tools-deps (63)
- # vim (24)
I’m trying to get items that have :item/id
and :item/uploadedAt
attributes (among others) and want to get the latest top 100 results. I get all ids and timestamps with a query first, sort the list and take 100. Then I want to do a second query to pull the required attributes for those entity ids. First I did:
(mapv (fn [id] (d/pull db pattern id)) ids)
To my surprise, this was actually very slow. So I replaced it with:
(d/q {:query '[:find (pull ?ids pattern)
:in $ [?ids ...] pattern]
:args [db ids pull-pattern]})
which is much faster.
The question is, is this (still) the best way to do this? And why is the first method much slower?Your mapv is 100 blocking pull requests with work done serially. Your query is one request with work done potentially in parallel
Yes it’s client (cloud). Thanks, so it’s still two sorts regardless.
Ofcourse, I lost the sort-ordering again in the second case…
@hadilsabbagh18 AWS has fixed the permissions on the AMI - you should be able to launch the latest now
@hadilsabbagh18 us-west-2 right?
Is there a way to install custom dependencies on the datomic ions EC2 instances? We are starting to use AWS xray for tracing but this requires a daemon process to be running for EC2 and I can’t see a straightforward way of installing this without hacking the cloudformation yaml for ions (which is not recommended per the docs).
If you can control the daemon from a Java lib then you can add that Java lib to your ion, but atm there is no supported path for deps other than Java libs.
Unfortunately it doesn’t look like there is one. Might have to move the logic to lambda if there’s no pathway there.
@hadilsabbagh18 yep - should be good now
(d/q {:query '[:find (pull ?e pattern)
:in $ ?name pattern
:where [?e :artist/name ?name]]
:args [db "The Beatles" [:artist/startYear :artist/endYear]]})
Unhandled clojure.lang.ExceptionInfo
Can't pull from history
{:datomic.client-spi/request-id "c4080ae6-32f4-414b-8359-6a4c0128b2ef",
:cognitect.anomalies/category :cognitect.anomalies/conflict,
:cognitect.anomalies/message "Can't pull from history",
:dbs
[{:database-id "956cc673-373e-4c39-8504-86f51b4cb11f",
:t 10,
:next-t 11,
:history false}]}