Fork me on GitHub
Lennart Buit21:08:35

Hey, I’m looking for some understanding, what makes this a much faster query:

(time (d/q '{:find [(count ?e)]
             :where [[?e :person/last-name ?last-name]
                     [(>= ?last-name "A")]
                     [(< ?last-name "B")]]}
           (d/db conn)))
Than this:
(time (d/q '{:find [(count ?e)]
             :where [(or-join [?e]
                       (and [?e :person/last-name ?last-name]
                            [(>= ?last-name "A")]
                            [(< ?last-name "B")]))]}
           (d/db conn)))
I’d say, these are the same queries right? Interestingly, before I added an index for :person/last-name they were about as fast... as in, same speed as the or-join version now is

Lennart Buit21:08:49

I understand the or-join is superfluous in this small example, I’m just wondering where this performance difference comes from