From a059460bd264308db022a85a308f4d1dcf72519e Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Mon, 10 Aug 2026 12:18:26 +0100 Subject: [PATCH] perf(database): index ProjectAlert.channelId so alert-channel deletes stop seq-scanning --- .server-changes/project-alert-channel-id-index.md | 6 ++++++ .../migration.sql | 2 ++ internal-packages/database/prisma/schema.prisma | 2 ++ 3 files changed, 10 insertions(+) create mode 100644 .server-changes/project-alert-channel-id-index.md create mode 100644 internal-packages/database/prisma/migrations/20260810120000_add_project_alert_channel_id_index/migration.sql diff --git a/.server-changes/project-alert-channel-id-index.md b/.server-changes/project-alert-channel-id-index.md new file mode 100644 index 00000000000..c9000c73f41 --- /dev/null +++ b/.server-changes/project-alert-channel-id-index.md @@ -0,0 +1,6 @@ +--- +area: webapp +type: improvement +--- + +Deleting an alert channel is now fast and no longer slows down as a project builds up alert history. diff --git a/internal-packages/database/prisma/migrations/20260810120000_add_project_alert_channel_id_index/migration.sql b/internal-packages/database/prisma/migrations/20260810120000_add_project_alert_channel_id_index/migration.sql new file mode 100644 index 00000000000..aada1a7ba36 --- /dev/null +++ b/internal-packages/database/prisma/migrations/20260810120000_add_project_alert_channel_id_index/migration.sql @@ -0,0 +1,2 @@ +-- CreateIndex +CREATE INDEX CONCURRENTLY IF NOT EXISTS "ProjectAlert_channelId_idx" ON "public"."ProjectAlert"("channelId"); diff --git a/internal-packages/database/prisma/schema.prisma b/internal-packages/database/prisma/schema.prisma index 545b0259539..5ce51d0db4b 100644 --- a/internal-packages/database/prisma/schema.prisma +++ b/internal-packages/database/prisma/schema.prisma @@ -2412,6 +2412,8 @@ model ProjectAlert { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + + @@index([channelId]) } enum ProjectAlertType {