chore: improve person & attribute query performance (#2161)

This commit is contained in:
Matti Nannt
2024-03-01 08:36:49 +01:00
committed by GitHub
parent 255f1cee61
commit dbbd450b62
3 changed files with 25 additions and 4 deletions
@@ -0,0 +1,20 @@
/*
Warnings:
- A unique constraint covering the columns `[personId,attributeClassId]` on the table `Attribute` will be added. If there are existing duplicate values, this will fail.
*/
-- DropIndex
DROP INDEX "Attribute_attributeClassId_personId_key";
-- DropIndex
DROP INDEX "AttributeClass_environmentId_idx";
-- CreateIndex
CREATE UNIQUE INDEX "Attribute_personId_attributeClassId_key" ON "Attribute"("personId", "attributeClassId");
-- CreateIndex
CREATE INDEX "AttributeClass_environmentId_created_at_idx" ON "AttributeClass"("environmentId", "created_at");
-- CreateIndex
CREATE INDEX "AttributeClass_environmentId_archived_idx" ON "AttributeClass"("environmentId", "archived");
+3 -2
View File
@@ -63,7 +63,7 @@ model Attribute {
personId String
value String
@@unique([attributeClassId, personId])
@@unique([personId, attributeClassId])
}
enum AttributeType {
@@ -86,7 +86,8 @@ model AttributeClass {
attributeFilters SurveyAttributeFilter[]
@@unique([name, environmentId])
@@index([environmentId])
@@index([environmentId, createdAt])
@@index([environmentId, archived])
}
model Person {