Skip to content

Commit 089d1e6

Browse files
committed
perf(database): index WorkerDeployment on (environmentId, status, id) for the deployments list
The deployments list query filters by status and paginates by id desc, but no index covered status, so Postgres seq-scanned the environment's deployments and discarded ~350 non-matching rows per row returned. Add (environmentId, status, id) so the status filter is index-satisfied and the scan is bounded to the page.
1 parent 7b7d489 commit 089d1e6

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: improvement
4+
---
5+
6+
Loading the deployments list is now faster, especially when filtering by deployment status on projects with many deployments.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "WorkerDeployment_environmentId_status_id_idx" ON "public"."WorkerDeployment"("environmentId", "status", "id");

internal-packages/database/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,6 +2214,7 @@ model WorkerDeployment {
22142214
@@unique([environmentId, version])
22152215
@@index([commitSHA])
22162216
@@index([environmentId, createdAt])
2217+
@@index([environmentId, status, id])
22172218
}
22182219

22192220
enum WorkerDeploymentStatus {

0 commit comments

Comments
 (0)