perf(audit-log): bound GetExecutionTreeAsync edge scan to a root-anchored time window (partition elimination)

This commit is contained in:
Joseph Doherty
2026-07-09 07:10:35 -04:00
parent f1957606ff
commit 5d0fcd4e66
3 changed files with 103 additions and 0 deletions
+11
View File
@@ -209,6 +209,17 @@ tag subscription) are also wired: trigger-driven runs carry `ParentExecutionId =
NULL` (top-level roots), and any nested `CallScript`/`CallShared` they perform
chains as above. The schema is unchanged — no further tag-cascade work is deferred.
**Execution-tree traversal bound.** `GetExecutionTreeAsync` first walks up
`ParentExecutionId` to the chain root, then walks down via a recursive CTE. The
down-walk's edge scan is bounded to a window anchored at the root's **first event**:
`[rootFirst 1 h, rootFirst + 7 d)` (configurable constants). Execution trees span
minutes, not years — an inbound request and everything it spawns fire inside one
operational burst — so the window lets SQL Server eliminate every `AuditLog`
partition outside it, turning a full-table `DISTINCT` scan into a seek on
`IX_AuditLog_Execution` (arch-review 04, P2). A genuine descendant stamped **beyond
the 7-day span is excluded by design**; a row-less stub root (its first event purged)
has no anchor and falls back to the unbounded scan (correctness over speed).
## The Site-Local `AuditLog` (SQLite)
A SQLite database file on each site node, alongside the Store-and-Forward