Skip to content

Schedules list performance #1938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/webapp/app/presenters/v3/ScheduleListPresenter.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export class ScheduleListPresenter extends BasePresenter {
},
active: true,
lastRunTriggeredAt: true,
createdAt: true,
},
where: {
projectId: project.id,
Expand Down Expand Up @@ -206,6 +207,9 @@ export class ScheduleListPresenter extends BasePresenter {
}
: undefined,
},
orderBy: {
createdAt: "desc",
},
take: pageSize,
skip: (page - 1) * pageSize,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- CreateIndex
CREATE INDEX CONCURRENTLY IF NOT EXISTS "TaskSchedule_projectId_idx" ON "TaskSchedule" ("projectId");

-- CreateIndex
CREATE INDEX CONCURRENTLY IF NOT EXISTS "TaskSchedule_projectId_createdAt_idx" ON "TaskSchedule" ("projectId", "createdAt" DESC);
3 changes: 3 additions & 0 deletions internal-packages/database/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -2933,6 +2933,9 @@ model TaskSchedule {
active Boolean @default(true)

@@unique([projectId, deduplicationKey])
/// Dashboard list view
@@index([projectId])
@@index([projectId, createdAt(sort: Desc)])
}

enum ScheduleType {
Expand Down