Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- User: optimize login/verification lookups.
-- The User table has low write volume (account creation/updates) relative to
-- the high read frequency of auth queries, making this a safe addition.
CREATE INDEX CONCURRENTLY IF NOT EXISTS "users_email_emailVerified_idx"
ON "users" ("email", "emailVerified");

-- Availability: optimize schedule-based date range lookups.
-- Availability has 3 existing indexes. This composite covers the common
-- query pattern of fetching schedule slots within a date range.
CREATE INDEX CONCURRENTLY IF NOT EXISTS "Availability_scheduleId_date_idx"
ON "Availability" ("scheduleId", "date");

-- Availability: optimize user-based date range lookups.
-- Covers the common pattern of fetching a user's availability for a date range.
CREATE INDEX CONCURRENTLY IF NOT EXISTS "Availability_userId_date_idx"
ON "Availability" ("userId", "date");
3 changes: 3 additions & 0 deletions packages/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ model User {
@@index([emailVerified])
@@index([identityProvider])
@@index([identityProviderId])
@@index([email, emailVerified])
@@map(name: "users")
}

Expand Down Expand Up @@ -998,6 +999,8 @@ model Availability {
@@index([userId])
@@index([eventTypeId])
@@index([scheduleId])
@@index([scheduleId, date])
@@index([userId, date])
}

model SelectedCalendar {
Expand Down
Loading