perf(sql): sweep/KPI covering indexes + sliced notification terminal purge
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
BEGIN TRANSACTION;
|
||||
IF NOT EXISTS (
|
||||
SELECT * FROM [__EFMigrationsHistory]
|
||||
WHERE [MigrationId] = N'20260814235335_AddAuditLogAndNotificationCoveringIndexes'
|
||||
)
|
||||
BEGIN
|
||||
EXEC(N'CREATE INDEX [IX_Notifications_Delivered] ON [Notifications] ([DeliveredAt]) WHERE [Status] = ''Delivered''');
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT * FROM [__EFMigrationsHistory]
|
||||
WHERE [MigrationId] = N'20260814235335_AddAuditLogAndNotificationCoveringIndexes'
|
||||
)
|
||||
BEGIN
|
||||
|
||||
DROP INDEX IX_AuditLog_OccurredAtUtc ON dbo.AuditLog;
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_AuditLog_OccurredAtUtc
|
||||
ON dbo.AuditLog (OccurredAtUtc DESC)
|
||||
INCLUDE (Status)
|
||||
ON ps_AuditLog_Month(OccurredAtUtc);
|
||||
END;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT * FROM [__EFMigrationsHistory]
|
||||
WHERE [MigrationId] = N'20260814235335_AddAuditLogAndNotificationCoveringIndexes'
|
||||
)
|
||||
BEGIN
|
||||
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
|
||||
VALUES (N'20260814235335_AddAuditLogAndNotificationCoveringIndexes', N'10.0.7');
|
||||
END;
|
||||
|
||||
COMMIT;
|
||||
GO
|
||||
|
||||
Reference in New Issue
Block a user