Commit Diff
- Commit:
d5d6368fec7b23d11d7729deb2291eb9c7751b58- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
- Message:
- 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) <noreply@anthropic.com>
- Actions:
- Patch | Tree
--- 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
