perf(sql): sweep/KPI covering indexes + sliced notification terminal purge
This commit is contained in:
+6
-1
@@ -185,9 +185,14 @@ public class AuditLogEntityTypeConfiguration : IEntityTypeConfiguration<AuditLog
|
||||
// column SETS migrate to the canonical/computed shape (alog.md §4 semantics
|
||||
// preserved): Channel→Category, Site/Node/Execution/ParentExecution now read
|
||||
// off the computed columns.
|
||||
// INCLUDE(Status) makes the audit KPI window query (count/aggregate by Status
|
||||
// over a recent OccurredAtUtc range) a covering index seek — the persisted
|
||||
// computed Status column rides along in the leaf without a key/RID lookup back
|
||||
// into the clustered index per matching row (arch-review WP1.4).
|
||||
builder.HasIndex(e => e.OccurredAtUtc)
|
||||
.IsDescending(true)
|
||||
.HasDatabaseName("IX_AuditLog_OccurredAtUtc");
|
||||
.HasDatabaseName("IX_AuditLog_OccurredAtUtc")
|
||||
.IncludeProperties(nameof(AuditLogRow.Status));
|
||||
|
||||
builder.HasIndex(e => new { e.SourceSiteId, e.OccurredAtUtc })
|
||||
.IsDescending(false, true)
|
||||
|
||||
+13
@@ -70,5 +70,18 @@ public class NotificationOutboxConfiguration : IEntityTypeConfiguration<Notifica
|
||||
builder.HasIndex(n => new { n.Status, n.NextAttemptAt });
|
||||
|
||||
builder.HasIndex(n => new { n.SourceSiteId, n.CreatedAt });
|
||||
|
||||
// Covers ComputeKpisAsync's "DeliveredLastInterval" count
|
||||
// (Status == Delivered && DeliveredAt >= deliveredSince): filtered to just the
|
||||
// Delivered rows so the index stays small relative to the full table and the KPI
|
||||
// query can seek it directly instead of scanning every status (arch-review WP1.4).
|
||||
// Status is stored as its enum name (HasConversion<string>() above), so the filter
|
||||
// predicate matches on the literal 'Delivered', not the underlying int value.
|
||||
// No N'' prefix: the value is ASCII-only (fine on SQL Server's nvarchar column)
|
||||
// and the repository tests' SQLite provider rejects the T-SQL N'' national-string
|
||||
// literal syntax outright when EnsureCreated() runs this filter as DDL.
|
||||
builder.HasIndex(n => n.DeliveredAt)
|
||||
.HasDatabaseName("IX_Notifications_Delivered")
|
||||
.HasFilter("[Status] = 'Delivered'");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user