Skip to content

perf(prisma): add composite indexes for User and Availability tables#28779

Draft
diogeneszilli wants to merge 1 commit intocalcom:mainfrom
diogeneszilli:perf/add-composite-indexes
Draft

perf(prisma): add composite indexes for User and Availability tables#28779
diogeneszilli wants to merge 1 commit intocalcom:mainfrom
diogeneszilli:perf/add-composite-indexes

Conversation

@diogeneszilli
Copy link
Copy Markdown

Summary

  • Add (email, emailVerified) composite index on User table to optimize login/verification lookups
  • Add (scheduleId, date) and (userId, date) composite indexes on Availability table to optimize date range queries
  • Migration uses CREATE INDEX CONCURRENTLY for zero-downtime deployment
  • Intentionally conservative: only targets tables with low existing index count (User: 4→5, Availability: 3→5) to avoid write amplification on index-heavy tables like Booking (12 indexes)

Test plan

  • Verify migration runs cleanly with yarn workspace @calcom/prisma db-migrate
  • Verify yarn prisma generate succeeds after schema change
  • Run yarn type-check:ci --force to confirm no type regressions

@github-actions github-actions bot added the ❗️ migrations contains migration files label Apr 7, 2026
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

❗️ migrations contains migration files size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants