Commit 94120ef
authored
fix(db): index decision_ledger_anchors on (row_hash, status) (#9830)
`anchorBackendsMissingForRowHash` (#9489) runs
`SELECT DISTINCT backend FROM decision_ledger_anchors WHERE row_hash = ? AND status = 'ok' AND backend IN (...)`
once per row being re-anchored, but the table had no index on row_hash — so each
call was a full table scan that grows with the anchor ledger.
Add migration 0203 creating `decision_ledger_anchors_row_hash_status (row_hash, status)`
— row_hash first (the equality predicate), status included so the `status = 'ok'`
filter is served from the index rather than a row fetch. Mirrors the
decision_ledger_record_id index added in 0198. The migration contains nothing else.
(Issue named 0202; that number is now taken, so this is the next contiguous 0203.)
A new test asserts the index exists after replaying migrations and that the real
query SEARCHes via it (not SCAN); the existing anchorBackendsMissingForRowHash
behaviour cases confirm results are unchanged.
Closes #96521 parent 4b1f5e2 commit 94120ef
2 files changed
Lines changed: 24 additions & 0 deletions
File tree
- migrations
- test/unit
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
243 | 261 | | |
0 commit comments