-
Notifications
You must be signed in to change notification settings - Fork 2
Add more indicies for better performance #5
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
-- CreateIndex | ||
CREATE INDEX "appeal_id_idx" ON "appeal"("id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "appeal_reviewItemCommentId_idx" ON "appeal"("reviewItemCommentId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "appealResponse_id_idx" ON "appealResponse"("id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "appealResponse_appealId_idx" ON "appealResponse"("appealId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "appealResponse_resourceId_idx" ON "appealResponse"("resourceId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "challengeResult_challengeId_idx" ON "challengeResult"("challengeId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "challengeResult_userId_idx" ON "challengeResult"("userId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "challengeResult_submissionId_idx" ON "challengeResult"("submissionId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "contactRequest_id_idx" ON "contactRequest"("id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "contactRequest_resourceId_idx" ON "contactRequest"("resourceId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "contactRequest_challengeId_idx" ON "contactRequest"("challengeId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "review_id_idx" ON "review"("id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "review_phaseId_idx" ON "review"("phaseId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "review_scorecardId_idx" ON "review"("scorecardId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "reviewItem_scorecardQuestionId_idx" ON "reviewItem"("scorecardQuestionId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "reviewItemComment_resourceId_idx" ON "reviewItemComment"("resourceId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "reviewItemComment_type_idx" ON "reviewItemComment"("type"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecard_id_idx" ON "scorecard"("id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecard_type_idx" ON "scorecard"("type"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecard_status_idx" ON "scorecard"("status"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecardGroup_id_idx" ON "scorecardGroup"("id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecardGroup_scorecardId_idx" ON "scorecardGroup"("scorecardId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecardGroup_sortOrder_idx" ON "scorecardGroup"("sortOrder"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecardQuestion_id_idx" ON "scorecardQuestion"("id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecardQuestion_scorecardSectionId_idx" ON "scorecardQuestion"("scorecardSectionId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecardQuestion_type_idx" ON "scorecardQuestion"("type"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecardQuestion_sortOrder_idx" ON "scorecardQuestion"("sortOrder"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecardSection_id_idx" ON "scorecardSection"("id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecardSection_scorecardGroupId_idx" ON "scorecardSection"("scorecardGroupId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "scorecardSection_sortOrder_idx" ON "scorecardSection"("sortOrder"); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,9 @@ model scorecard { | |
@@index([challengeTrack]) | ||
@@index([challengeType]) | ||
@@index([name]) | ||
@@index([id]) // Index for direct ID lookups | ||
@@index([type]) // Index for filtering by scorecard type | ||
@@index([status]) // Index for filtering by status (e.g. ACTIVE scorecards) | ||
} | ||
|
||
enum ScorecardStatus { | ||
|
@@ -77,6 +80,10 @@ model scorecardGroup { | |
|
||
scorecard scorecard @relation(fields: [scorecardId], references: [id], onDelete: Cascade) | ||
sections scorecardSection[] | ||
|
||
@@index([id]) // Index for direct ID lookups | ||
@@index([scorecardId]) // Index for joining with scorecard table | ||
@@index([sortOrder]) // Index for ordering groups | ||
} | ||
|
||
model scorecardSection { | ||
|
@@ -93,6 +100,10 @@ model scorecardSection { | |
|
||
group scorecardGroup @relation(fields: [scorecardGroupId], references: [id], onDelete: Cascade) | ||
questions scorecardQuestion[] | ||
|
||
@@index([id]) // Index for direct ID lookups | ||
@@index([scorecardGroupId]) // Index for joining with scorecardGroup table | ||
@@index([sortOrder]) // Index for ordering sections | ||
} | ||
|
||
enum QuestionType { | ||
|
@@ -121,6 +132,11 @@ model scorecardQuestion { | |
scaleMax Int? // Maximum value for scale (used when type is SCALE) | ||
|
||
section scorecardSection @relation(fields: [scorecardSectionId], references: [id], onDelete: Cascade) | ||
|
||
@@index([id]) // Index for direct ID lookups | ||
@@index([scorecardSectionId]) // Index for joining with scorecardSection table | ||
@@index([type]) // Index for filtering questions by type | ||
@@index([sortOrder]) // Index for ordering questions | ||
} | ||
|
||
model review { | ||
|
@@ -141,9 +157,12 @@ model review { | |
scorecard scorecard @relation(fields: [scorecardId], references: [id], onDelete: Cascade) | ||
reviewItems reviewItem[] | ||
|
||
@@index([committed]) // Add index for the committed field | ||
@@index([submissionId]) // Index for submissionId field | ||
@@index([resourceId]) // Index for resourceId field | ||
@@index([committed]) // Index for filtering by committed status | ||
@@index([submissionId]) // Index for filtering by submission | ||
@@index([resourceId]) // Index for filtering by resource (reviewer) | ||
@@index([id]) // Index for direct ID lookups | ||
@@index([phaseId]) // Index for filtering by phase | ||
@@index([scorecardId]) // Index for joining with scorecard table | ||
} | ||
|
||
model reviewItem { | ||
|
@@ -162,8 +181,9 @@ model reviewItem { | |
|
||
review review @relation(fields: [reviewId], references: [id], onDelete: Cascade) | ||
reviewItemComments reviewItemComment[] | ||
@@index([reviewId]) // Index for reviewId field | ||
@@index([id]) // Index for id field | ||
@@index([reviewId]) // Index for joining with review table | ||
@@index([id]) // Index for direct ID lookups | ||
@@index([scorecardQuestionId]) // Index for joining with scorecardQuestion table | ||
} | ||
|
||
model reviewItemComment { | ||
|
@@ -181,8 +201,10 @@ model reviewItemComment { | |
|
||
reviewItem reviewItem @relation(fields: [reviewItemId], references: [id], onDelete: Cascade) | ||
appeal appeal? | ||
@@index([reviewItemId]) // Index for reviewItemId field | ||
@@index([id]) // Index for id field | ||
@@index([reviewItemId]) // Index for joining with reviewItem table | ||
@@index([id]) // Index for direct ID lookups | ||
@@index([resourceId]) // Index for filtering by resource (commenter) | ||
@@index([type]) // Index for filtering by comment type | ||
} | ||
|
||
enum ReviewItemCommentType { | ||
|
@@ -214,7 +236,9 @@ model appeal { | |
reviewItemComment reviewItemComment @relation(fields: [reviewItemCommentId], references: [id], onDelete: Cascade) // Define fields and references here | ||
appealResponse appealResponse? | ||
|
||
@@index([resourceId]) // Index for resourceId field | ||
@@index([resourceId]) // Index for resource ID | ||
@@index([id]) // Index for direct ID lookups | ||
@@index([reviewItemCommentId]) // Index for joining with reviewItemComment table | ||
} | ||
|
||
model appealResponse { | ||
|
@@ -230,6 +254,10 @@ model appealResponse { | |
updatedBy String | ||
|
||
appeal appeal @relation(fields: [appealId], references: [id], onDelete: Cascade) | ||
|
||
@@index([id]) // Index for direct ID lookups | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The index on |
||
@@index([appealId]) // Index for joining with appeal table | ||
@@index([resourceId]) // Index for filtering by resource (responder) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that the |
||
} | ||
|
||
model challengeResult { | ||
|
@@ -254,6 +282,9 @@ model challengeResult { | |
updatedBy String | ||
|
||
@@id([challengeId, userId]) | ||
@@index([challengeId]) // Index for filtering by challenge | ||
@@index([userId]) // Index for filtering by user | ||
@@index([submissionId]) // Index for filtering by submission | ||
} | ||
|
||
model contactRequest { | ||
|
@@ -265,4 +296,8 @@ model contactRequest { | |
createdBy String | ||
updatedAt DateTime @updatedAt | ||
updatedBy String | ||
|
||
@@index([id]) // Index for direct ID lookups | ||
@@index([resourceId]) // Index for filtering by resource (requester) | ||
@@index([challengeId]) // Index for filtering by challenge | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The index on the
id
field might be redundant ifid
is already the primary key, as primary keys are indexed by default. Consider verifying if this index is necessary.