Optimize for speed without sacrificing clarity
All JPA queries must have appropriate indexes designed for expected data volumes, with composite indexes for multi-column filters using @Index annotations and covering indexes for read-heavy workloads to maintain sub-second query performance.
All database queries must be profiled using Hibernate statistics, P6Spy, or custom JPA interceptors for execution time, I/O costs, and resource usage with automated alerts for queries exceeding performance thresholds or showing degradation over time.
All bulk database operations using Spring Batch, JPA batch processing, or custom batch implementations must implement dynamic batch sizing based on infrastructure capabilities, network latency, and memory constraints to optimize throughput without overwhelming systems.