Fork me on GitHub
#xtdb
<
2022-03-10
>
flefik17:03:48

How can I make the equivalent of a left outer group by join in xtdb?

'{:find [d1 (sum du)]
                            :where [
                                    [d1 :type :deliverable]
                                    [tc :type :timecard]
                                    [tc :duration du]
                                    [tc :deliverable d1]
                                    ]}
If there’s no timecard for a deliverable, the deliverable isn’t returned in this query. I’d like for it to be returned (and the sum be zero) even if there’s no timecard. Any way to do this without resorting to an n+1 query?

refset17:03:18

Hey @UAEFFG05B I'll dig into this shortly, but on first glance it looks remarkably similar to the very last thread in this channel, so maybe there's some clues there 🙂 see https://clojurians.slack.com/archives/CG3AM2F7V/p1646912505901429?thread_ts=1646671389.384489&amp;cid=CG3AM2F7V

🙂 1
flefik17:03:42

Hah you’re right!

flefik17:03:43

I’ll look

flefik17:03:55

Looks like you’re suggesting an n+1 query. Okay I’ll do that!

refset17:03:39

kind of n+1 (not recursive, at least), but it's all happening in-process so it shouldn't be a performance concern 🙂

flefik18:03:08

(or-join [du d1]
                                             (and [tc :type :timecard]
                                                  [tc :duration du]
                                                  [tc :deliverable d1])
                                             (and [(identity 0) du]
                                                  [d1 :type :deliverable])
                                             )
seems to work, thanks @U899JBRPF

🙌 1
refset22:03:43

awesome, glad to hear that 🙂