Skip to content

Commit 2b757a6

Browse files
committed
perf: Index report type, relation kind and series keys
1 parent 87fc412 commit 2b757a6

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

resources/bone-schema.edn

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
;; (Mailman/DMARC munging style). All downstream code (participants,
3232
;; commands, roles, reports, exports) reads author-address.
3333
:email/author-name {:db/valueType :db.type/string}
34+
;; Not indexed: stored verbatim, so value lookups must be
35+
;; case-insensitive (bone.digest/open-patch-eids-by-sender compares
36+
;; lowercased in a predicate, anchored on the :report/type index).
3437
:email/author-address {:db/valueType :db.type/string}
3538
:email/to {:db/valueType :db.type/string
3639
:db/cardinality :db.cardinality/many}
@@ -86,7 +89,10 @@
8689
;; to :email/author-address) or, for proxy-capable state attrs, via
8790
;; the cached `-address` attr below -- which may diverge from the
8891
;; email's author-address when a maintainer uses the `-by` form.
89-
:report/type {:db/valueType :db.type/keyword}
92+
;; Indexed: every "open reports of type X" query (auto-supersede,
93+
;; series, release :change closing, ...) filters by exact value.
94+
:report/type {:db/valueType :db.type/keyword
95+
:db/index true}
9096
:report/email {:db/valueType :db.type/ref}
9197
;; Raw root Message-Id, kept verbatim for display/export; identity
9298
;; and lookups go through the hash (as for :email/message-id).
@@ -184,7 +190,12 @@
184190
:db/unique :db.unique/identity}
185191
:rel/from {:db/valueType :db.type/ref}
186192
:rel/to {:db/valueType :db.type/ref}
187-
:rel/kind {:db/valueType :db.type/keyword}
193+
;; Indexed: :rel is the highest-cardinality entity, and nearly every
194+
;; bone.relations query filters by a bound :rel/kind. (Not :rel/active?:
195+
;; a boolean is barely more selective than a scan -- :rel/kind carries
196+
;; the selectivity, :rel/active? is a cheap post-filter.)
197+
:rel/kind {:db/valueType :db.type/keyword
198+
:db/index true}
188199
:rel/setter {:db/valueType :db.type/string}
189200
:rel/email {:db/valueType :db.type/ref}
190201
:rel/posed-at {:db/valueType :db.type/instant}
@@ -203,8 +214,12 @@
203214
;; --- Patch series ---
204215
:series/id {:db/valueType :db.type/string
205216
:db/unique :db.unique/identity}
206-
:series/topic {:db/valueType :db.type/string}
207-
:series/sender {:db/valueType :db.type/string}
217+
;; Two independent AVET indexes (not a composite): every series
218+
;; lookup binds both values, either index narrows the scan.
219+
:series/topic {:db/valueType :db.type/string
220+
:db/index true}
221+
:series/sender {:db/valueType :db.type/string
222+
:db/index true}
208223
:series/expected {:db/valueType :db.type/long}
209224
:series/cover-letter {:db/valueType :db.type/ref}
210225
:series/patches {:db/valueType :db.type/ref

0 commit comments

Comments
 (0)