perf(sitecallaudit): filtered IX_SiteCalls_Terminal index backs the retention purge predicate (plan R2-04 T10)

This commit is contained in:
Joseph Doherty
2026-07-13 10:23:19 -04:00
parent 439dee52d3
commit 3d6973cc89
6 changed files with 2168 additions and 0 deletions
@@ -94,6 +94,22 @@ public class SchemaConfigurationTests : IDisposable
new[] { nameof(SiteCall.SourceSite), nameof(SiteCall.SourceNode), nameof(SiteCall.Status) },
index.GetIncludeProperties());
}
// arch-review 04 round 2 (R6): the daily terminal retention purge filters on
// TerminalAtUtc IS NOT NULL AND TerminalAtUtc < cutoff. A filtered index over the
// terminal population lets the purge (and Task 11's MIN() slice anchor) seek the
// expired tail instead of full-scanning the 365-day table. Locked shape:
// key = TerminalAtUtc, filter = [TerminalAtUtc] IS NOT NULL.
[Fact]
public void SiteCalls_Has_Filtered_Terminal_Index()
{
var model = _context.GetService<IDesignTimeModel>().Model;
var entity = model.FindEntityType(typeof(SiteCall))!;
var index = entity.GetIndexes().Single(i => i.GetDatabaseName() == "IX_SiteCalls_Terminal");
Assert.Equal(new[] { nameof(SiteCall.TerminalAtUtc) }, index.Properties.Select(p => p.Name).ToArray());
Assert.Equal("[TerminalAtUtc] IS NOT NULL", index.GetFilter());
}
}
public class SplitQueryBehaviourTests : IDisposable