mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
3d0663f4af
* feat: add composite indexes for booking queries at scale Add new composite indexes to optimize common query patterns for the Booking and Attendee tables. These indexes are designed to support the system at scale (14M+ bookings, 50K daily inserts) while minimizing write overhead. New indexes on Booking table: - (userId, endTime): Optimizes /bookings/upcoming queries - (userId, status, startTime): Optimizes busy times and filtered queries - (eventTypeId, status): Optimizes round-robin and team booking queries - (userId, createdAt): Optimizes API queries with createdAt sorting New index on Attendee table: - (bookingId, email): Optimizes JOIN queries filtering by attendee email These indexes target the most common query patterns identified in: - get.handler.ts (bookings list endpoints) - BookingRepository.ts (busy times, round-robin) - API v1 bookings endpoint Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * feat: add migration file for booking composite indexes Add SQL migration to create the new composite indexes: - Attendee(bookingId, email) - Booking(userId, endTime) - Booking(userId, status, startTime) - Booking(eventTypeId, status) - Booking(userId, createdAt) Also clean up comments in schema.prisma to be more generic. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: swap Attendee index column order to (email, bookingId) Per Cubic AI review feedback - place email first to match the filter column order in queries that filter by email. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>