perf(site-call-audit): filtered IX_SiteCalls_NonTerminal index — KPI predicates seek the live queue instead of scanning 365 days
This commit is contained in:
+14
-2
@@ -66,8 +66,9 @@ public class SiteCallEntityTypeConfiguration : IEntityTypeConfiguration<SiteCall
|
||||
// SourceNode (SourceNode-stamping): node-local identifier of the
|
||||
// cluster member that produced the call (e.g. "node-a", "central-a"). NULL is
|
||||
// valid for rows that pre-date this feature and for reconciled rows from a
|
||||
// retired node. ASCII — varchar(64). No index — Site Call Audit KPIs are
|
||||
// per-site, not per-node, on this table.
|
||||
// retired node. ASCII — varchar(64). Not a key column of any index, but it rides
|
||||
// as an INCLUDE column on IX_SiteCalls_NonTerminal below so the per-node KPI
|
||||
// breakdown reads it covered off the filtered live-queue index.
|
||||
builder.Property(s => s.SourceNode)
|
||||
.HasColumnType("varchar(64)")
|
||||
.HasMaxLength(64)
|
||||
@@ -85,5 +86,16 @@ public class SiteCallEntityTypeConfiguration : IEntityTypeConfiguration<SiteCall
|
||||
builder.HasIndex(s => new { s.Status, s.UpdatedAtUtc })
|
||||
.IsDescending(false, true)
|
||||
.HasDatabaseName("IX_SiteCalls_Status_Updated");
|
||||
|
||||
// NonTerminal backs every "live queue" KPI predicate (TerminalAtUtc IS NULL):
|
||||
// buffered/stuck/oldest counts run every 60 s from the KPI recorder plus every
|
||||
// 10 s Health-dashboard poll. Filtered: the non-terminal population is the live
|
||||
// queue, not the 365-day archive — each count becomes a small seek instead of a
|
||||
// clustered scan (arch-review 04, P1). SourceSite/SourceNode/Status ride as
|
||||
// INCLUDE columns so the per-site + per-node KPI breakdowns stay covered.
|
||||
builder.HasIndex(s => s.CreatedAtUtc)
|
||||
.HasDatabaseName("IX_SiteCalls_NonTerminal")
|
||||
.HasFilter("[TerminalAtUtc] IS NULL")
|
||||
.IncludeProperties(nameof(SiteCall.SourceSite), nameof(SiteCall.SourceNode), nameof(SiteCall.Status));
|
||||
}
|
||||
}
|
||||
|
||||
+2015
File diff suppressed because it is too large
Load Diff
+29
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddSiteCallsNonTerminalIndex : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SiteCalls_NonTerminal",
|
||||
table: "SiteCalls",
|
||||
column: "CreatedAtUtc",
|
||||
filter: "[TerminalAtUtc] IS NULL")
|
||||
.Annotation("SqlServer:Include", new[] { "SourceSite", "SourceNode", "Status" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_SiteCalls_NonTerminal",
|
||||
table: "SiteCalls");
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -161,6 +161,12 @@ namespace ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Migrations
|
||||
|
||||
b.HasKey("TrackedOperationId");
|
||||
|
||||
b.HasIndex("CreatedAtUtc")
|
||||
.HasDatabaseName("IX_SiteCalls_NonTerminal")
|
||||
.HasFilter("[TerminalAtUtc] IS NULL");
|
||||
|
||||
SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex("CreatedAtUtc"), new[] { "SourceSite", "SourceNode", "Status" });
|
||||
|
||||
b.HasIndex("SourceSite", "CreatedAtUtc")
|
||||
.IsDescending(false, true)
|
||||
.HasDatabaseName("IX_SiteCalls_Source_Created");
|
||||
|
||||
Reference in New Issue
Block a user