datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
2020-08-21T21:01:35.034800Z

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

1➕
2020-08-21T21:02:49.035100Z

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