fix(perf): don't call d/datoms to get all eavt

It's too slow (+8s) for a 500m sqlite file to just insert a new block
This commit is contained in:
Tienson Qin
2026-04-14 00:27:36 +08:00
parent 00bcdba6c5
commit 0958e1f402

View File

@@ -52,8 +52,9 @@
[{:keys [db-after tx-data tx-meta] :as tx-report} {:keys [closed-schema?]}]
(binding [db-malli-schema/*skip-strict-url-validate?* true]
(let [changed-ids (->> tx-data (keep :e) distinct)
datoms (d/datoms db-after :eavt)
tx-datoms (mapcat (fn [id] (filter (fn [d] (= (:e d) id)) datoms)) changed-ids)
tx-datoms (mapcat (fn [id]
(d/datoms db-after :eavt id))
changed-ids)
ent-maps* (map (fn [[db-id m]]
;; Add :db/id for debugging
(assoc m :db/id db-id))