This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-30
Channels
- # announcements (4)
- # babashka (8)
- # beginners (124)
- # calva (13)
- # cider (10)
- # circleci (6)
- # clj-kondo (193)
- # cljdoc (1)
- # cljs-dev (4)
- # clojure (50)
- # clojure-europe (28)
- # clojure-serbia (1)
- # clojure-spec (22)
- # clojure-uk (30)
- # clojurescript (11)
- # clojureverse-ops (3)
- # community-development (1)
- # conjure (5)
- # cursive (1)
- # datomic (11)
- # depstar (1)
- # events (2)
- # fulcro (7)
- # graalvm (2)
- # graphql (10)
- # helix (43)
- # hyperfiddle (14)
- # introduce-yourself (6)
- # jobs (2)
- # jobs-discuss (14)
- # kaocha (4)
- # luminus (2)
- # malli (24)
- # meander (6)
- # off-topic (4)
- # pathom (1)
- # polylith (13)
- # re-frame (6)
- # releases (1)
- # remote-jobs (1)
- # sci (14)
- # shadow-cljs (209)
- # tools-deps (30)
- # xtdb (26)
say I have a relationship between two entities foo
and bar
--I can express it with a join :foo/bar-join
or :bar/foo-join
. If I know that the majority of the time I will be querying for bar
s given some foo
instead of vice versa, would it be much more efficient to have :foo/bar-join
instead of :bar/foo-join
? My best guess is that the performance of this query for :foo/bar-join
has to be the most performant one, since the query engine would just have to look at what values are in the join attribute on the entity whose ID we already know, but I'm not sure just how much worse I can expect a :bar/foo-join
to be
Hey @U49U72C4V 👋 I don't think Crux will care that much either way - we strip documents down into EAV triples into the indices, and then the query planner will be able to navigate the join in either direction depending on which variable it thinks is smallest.
i.e. if your query has a good filter on foo
somewhere, it'll pick that first and then navigate to bar
, and vice versa
We also keep indices both ways - AEV and AVE, so if you have E in hand we'll use AEV; V in hand we'll use AVE (we always have A)
In short, I'd probably prioritise modelling based on the cardinality of the relationship instead - i.e. if it's a parent:children relationship, a field on each child referencing its parent
thank you, appreciate the answer! that's a relief--my case is a parent-child relationship, so i'll happily be putting the join on children then
this is interesting, I though one reference would be fine and the reverse join /_foo
feature would take care of the rest...would it be possible to do it that way?
Is there a performance hit in using the reverse join?
@U0C8489U6 - not sure I quite understand your question I'm afraid - but yep, one reference from child to parent is fine. By reverse join, do you mean :where [[?child :has-parent ?parent]]
(if so, yep, no performance hit, as outlined above) or the reverse joins in the pull API (if so, also there shouldn't be a performance hit - this also uses the AVE indices)?
maybe an example would help?
Yeah sorry - I meant the reverse join in the pull child/_has-parent
basically
and just was wondering what is the preferred way if any - I am very happy how terse the pull syntax is if no major drawbacks to it thanks!
Evening - 1.18.0 is out 🚀
* Significant improvements to the Lucene module - it now supports checkpointing, in-memory Lucene, and Crux will now ensure the Lucene index is up-to-date on startup. Requires a Lucene re-index for folks who have Lucene indices.
* Ability to add 'secondary indices' (of which Lucene is the first) - custom indices that follow the Crux tx-log alongside the main indices. Can be used (for example) to create materialized views of your Crux transactions in other formats/stores - we're intrigued to see how folks use this 🙂
* First alpha release of crux-corda
- adds the Corda blockchain (https://corda.net) as a possible source of Crux transactions, allowing you to query both the current and historical state of your Corda nodes using Crux's temporal queries. Keep your eyes peeled for some blogs over the coming weeks!
* All the usual bugfixes 🐛
For more details, see the release notes at https://github.com/juxt/crux/releases/tag/1.18.0.
As always, a big thanks to everyone contributing to this release by raising/fixing issues, and helping us with repros!
Congrats on the release. I'm curious about the corda support. May I ask how that particular blockchain ecosystem was chosen and if there are plans to add others?
The Corda blockchain was already in use on an existing client project and the adapter was built at their request. We could very well build more adapters in the future, but doing so either depends on customer demand or community contributions. It's not a specific goal of Crux to have a lot of blockchain adapters — we're just happy to build them if companies find them useful. 🙂
hey Im trying to delete all crux entries in between tests, whats the best way of doing it? reading all entries and evicting one by one in a tx?
yeah, that's what I do in my project https://github.com/lgessler/glam/blob/master/src/test/glam/crux/project_test.clj#L10L13
I need some help understanding entity-history
;; When submitting a single tx for valid range 2001 to 2002 on an in-memory node
(crux.api/submit-tx
crux
[[:crux.tx/put {:crux.db/id "test"} #inst "2001" #inst "2002"]]
;; I expect no history when specifying a later valid time range,
;; but get the tx with a valid time of 2001-2002
(crux.api/entity-history
(crux.api/db crux) "test"
:asc
{:with-docs? true
:start {:crux.db/valid-time #inst "2020"}
:end {:crux.db/valid-time #inst "2021"}})
;; Result
[{:crux.tx/tx-time #inst "2021-07-30T21:43:43.644-00:00",
:crux.tx/tx-id 0,
:crux.db/valid-time #inst "2001-01-01T00:00:00.000-00:00",
:crux.db/content-hash
#crux/id "5357154b961bd22dc5ddbc7fec9580419964976c",
:crux.db/doc #:crux.db{:id "test"}}
{:crux.tx/tx-time #inst "2021-07-30T21:43:43.644-00:00",
:crux.tx/tx-id 0,
:crux.db/valid-time #inst "2002-01-01T00:00:00.000-00:00",
:crux.db/content-hash
#crux/id "0000000000000000000000000000000000000000",
:crux.db/doc nil}]
Start and end bounds aren't specified using maps like that (anymore), see https://opencrux.com/reference/1.18.0/clojure-api.html#_entity_history
Hmm , thanks @U899JBRPF. Did that just change in 1.18.0 ? I had been using 1.17.1 and referencing https://opencrux.com/reference/1.18.0/queries.html#history-document-history-range.
Ah, yeah the docs fix only just got published 😅. Feels like an age since I fixed it already though: https://github.com/juxt/crux/commit/a8000e312a2788c7093111b4debd488bb4c5a52e