improvement(db): added missing indexes for common access patterns (#2473)

This commit is contained in:
Waleed
2025-12-19 00:46:10 -08:00
committed by GitHub
parent 3a33ec929f
commit 889b44c90a
4 changed files with 7816 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
CREATE INDEX "api_key_workspace_type_idx" ON "api_key" USING btree ("workspace_id","type");--> statement-breakpoint
CREATE INDEX "api_key_user_type_idx" ON "api_key" USING btree ("user_id","type");--> statement-breakpoint
CREATE INDEX "verification_expires_at_idx" ON "verification" USING btree ("expires_at");--> statement-breakpoint
CREATE INDEX "workflow_blocks_type_idx" ON "workflow_blocks" USING btree ("type");

File diff suppressed because it is too large Load Diff

View File

@@ -869,6 +869,13 @@
"when": 1766108872186,
"tag": "0124_blushing_colonel_america",
"breakpoints": true
},
{
"idx": 125,
"version": "7",
"when": 1766133598113,
"tag": "0125_eager_lily_hollister",
"breakpoints": true
}
]
}

View File

@@ -108,6 +108,7 @@ export const verification = pgTable(
},
(table) => ({
identifierIdx: index('verification_identifier_idx').on(table.identifier),
expiresAtIdx: index('verification_expires_at_idx').on(table.expiresAt),
})
)
@@ -197,6 +198,7 @@ export const workflowBlocks = pgTable(
},
(table) => ({
workflowIdIdx: index('workflow_blocks_workflow_id_idx').on(table.workflowId),
typeIdx: index('workflow_blocks_type_idx').on(table.type),
})
)
@@ -618,6 +620,8 @@ export const apiKey = pgTable(
'workspace_type_check',
sql`(type = 'workspace' AND workspace_id IS NOT NULL) OR (type = 'personal' AND workspace_id IS NULL)`
),
workspaceTypeIdx: index('api_key_workspace_type_idx').on(table.workspaceId, table.type),
userTypeIdx: index('api_key_user_type_idx').on(table.userId, table.type),
})
)