Minor perf improvement: create idx_tx_lookup_added after populating tx_lookup.
This commit is contained in:
parent
2a55b138f6
commit
f53869ba6f
2 changed files with 7 additions and 2 deletions
|
@ -238,6 +238,7 @@
|
||||||
many? (memoize (fn [a] (ds/multival? schema a)))
|
many? (memoize (fn [a] (ds/multival? schema a)))
|
||||||
<exec (partial s/execute! (:sqlite-connection db))]
|
<exec (partial s/execute! (:sqlite-connection db))]
|
||||||
(p :delete-tx-lookup-before
|
(p :delete-tx-lookup-before
|
||||||
|
(<? (<exec ["DROP INDEX IF EXISTS id_tx_lookup_added"]))
|
||||||
(<? (<exec ["DELETE FROM tx_lookup"])))
|
(<? (<exec ["DELETE FROM tx_lookup"])))
|
||||||
|
|
||||||
(p :insertions
|
(p :insertions
|
||||||
|
@ -303,6 +304,9 @@
|
||||||
(catch java.sql.SQLException e
|
(catch java.sql.SQLException e
|
||||||
(throw (ex-info "Transaction violates cardinality constraint" {} e))))) ;; TODO: say more about the conflicting datoms.
|
(throw (ex-info "Transaction violates cardinality constraint" {} e))))) ;; TODO: say more about the conflicting datoms.
|
||||||
|
|
||||||
|
(p :create-tx-lookup-indices
|
||||||
|
(<? (<exec ["CREATE INDEX IF NOT EXISTS idx_tx_lookup_added ON tx_lookup (added0)"])))
|
||||||
|
|
||||||
(p :join
|
(p :join
|
||||||
;; Fast, only one table walk: lookup by exact eav.
|
;; Fast, only one table walk: lookup by exact eav.
|
||||||
(p :join-eav
|
(p :join-eav
|
||||||
|
@ -348,6 +352,7 @@
|
||||||
|
|
||||||
;; The lookup table takes space on disk, so we purge it aggressively.
|
;; The lookup table takes space on disk, so we purge it aggressively.
|
||||||
(p :delete-tx-lookup-after
|
(p :delete-tx-lookup-after
|
||||||
|
(<? (<exec ["DROP INDEX IF EXISTS id_tx_lookup_added"]))
|
||||||
(<? (<exec ["DELETE FROM tx_lookup"])))
|
(<? (<exec ["DELETE FROM tx_lookup"])))
|
||||||
|
|
||||||
;; The transaction has been written -- read it back. (We index on tx, so the following is fast.)
|
;; The transaction has been written -- read it back. (We index on tx, so the following is fast.)
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
rid INTEGER,
|
rid INTEGER,
|
||||||
e INTEGER, a SMALLINT, v BLOB, tx INTEGER, value_type_tag SMALLINT)"
|
e INTEGER, a SMALLINT, v BLOB, tx INTEGER, value_type_tag SMALLINT)"
|
||||||
|
|
||||||
"CREATE INDEX idx_tx_lookup_added ON tx_lookup (added0)"
|
;; Note that `id_tx_lookup_added` is created and dropped
|
||||||
|
;; after insertion, which makes insertion slightly faster.
|
||||||
;; Prevent overlapping transactions. TODO: drop added0?
|
;; Prevent overlapping transactions. TODO: drop added0?
|
||||||
"CREATE UNIQUE INDEX idx_tx_lookup_eavt ON tx_lookup (e0, a0, v0, added0, value_type_tag0) WHERE sv IS NOT NULL"
|
"CREATE UNIQUE INDEX idx_tx_lookup_eavt ON tx_lookup (e0, a0, v0, added0, value_type_tag0) WHERE sv IS NOT NULL"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue