commit d5d6368fec7b23d11d7729deb2291eb9c7751b58 from: Alisdair MacLeod date: Tue Mar 31 18:52:18 2026 UTC Add index on bookings(day) for day-specific queries The existing UNIQUE indexes have (desk, day) and (user, day) as their column order, so queries that filter by day alone cannot seek directly. This index lets the day bookings and LEFT JOIN queries use an index scan instead of a full table scan. Co-Authored-By: Claude Opus 4.6 (1M context) commit - 22f3a7ce67aefccfc7d2c6871c9168ec89319e29 commit + d5d6368fec7b23d11d7729deb2291eb9c7751b58 blob - 0c020f0d76f5ec6fe28a3d7a41aaa8c56182fe33 blob + dadd4640f92ccae86995fa3aefebd7851d70b836 --- sql/migrate_bookings.sql +++ sql/migrate_bookings.sql @@ -5,4 +5,5 @@ CREATE TABLE IF NOT EXISTS bookings ( FOREIGN KEY(desk) REFERENCES desks(desk) ON DELETE CASCADE, UNIQUE(desk, day), UNIQUE(user, day) -) STRICT; \ No newline at end of file +) STRICT; +CREATE INDEX IF NOT EXISTS idx_bookings_day ON bookings(day); \ No newline at end of file