Advanced
Performance tuning, database indexes, and high-concurrency patterns for production deployments.
Performance tuning, database indexes, and high-concurrency patterns.
Recommended Database Indexes
For production deployments with high booking volume, add these indexes to your database. The conflict detection query filters by resource, status, startTime, and endTime on every create and update — the composite reservation_conflict_lookup index is the most important one to add.
The idempotencyKey field has unique: true in the Payload schema definition, so Payload-managed databases will have this automatically. The snippets above are for manually adding it if your database was created before this field was introduced.
Reconciliation Job
For high-concurrency deployments, rare race conditions between two simultaneous bookings can slip past the hook-level conflict check. A background reconciliation job can detect and flag these after the fact.
Add this to your Payload config's jobs.tasks array:
Run this job on a schedule (e.g., hourly) using Payload's job queue. The job does not resolve conflicts automatically — it flags them for human review.