         (let [non-consts (set/difference syms (set (keys (:consts context))))]
           (if (empty? non-consts)
             context ;; join was by constants only, nothing changes
-            (let [sets (map #(collect % non-consts) contexts)
-                  rel  (coll-rel non-consts (into (first sets) cat (next sets)))]
+            (let [arrays (map #(collect-to % non-consts (fast-arr) []) contexts)
+                  rel    (array-rel non-consts (into (first arrays) cat (next arrays)))]
               (hash-join-rel context rel))))))
     "resolve-or" (dp/source clause)))
 

            result))))))


(defn collect [context syms]
  (perf/measure
    (if (:empty? context)
      (fast-set)
      (let [syms-indexed (vec (shim/zip syms (range)))
            specimen     (shim/make-array (count syms))
            _            (collect-consts syms-indexed specimen (:consts context))
            related-rels (related-rels context syms)
            xfs          (-> (map #(collect-rel-xf syms-indexed %) related-rels)
                             (concat [(map vec)]))]
        (into (fast-set) (apply comp xfs) [specimen])))
   "collect"))


;; Query

(def query-cache (volatile! (datascript.lru/lru lru-cache-size)))


                      (fn [set tuple]
                        (conj! set (getter tuple))))
               (persistent!)))))
    (collect-to context syms (fast-set) [(map vec)])))


(defn subtract-from-rel [rel syms exclude-key-set]
