What problem does it solve?
Backend services often ship with hidden performance traps: N+1 queries inside loops, oversized IN clauses, unbounded BFS traversals, and duplicated heavy queries across nested service calls. These pass local testing but collapse under production data volumes. This Skill gives the AI concrete detection patterns and fixes for these query performance pitfalls.
Core Features & Use Cases
- N+1 Detection and Repair: Identifies single-record queries inside loops, streams, and DTO converters, then rewrites them using the batch-fetch-then-map-lookup pattern.
- IN Clause Batching: Enforces a fixed batch size (e.g., 500) for large ID lists and aggregate SUM/COUNT queries to avoid packet limits and plan-cache misses.
- Bounded Traversal: Adds MAX_TOTAL_NODES limits with truncation logging to BFS/recursive structures like invite trees and org charts.
- Use Case: While reviewing a Java Spring service that converts 6000 products to DTOs in a loop, the Skill flags the implicit N+1 (4 queries per item) and rewrites it with two-phase processing and preloaded maps, cutting thousands of SQL round trips to a handful.
Quick Start
Review this service method for N+1 queries, unbatched IN clauses, and unbounded recursion, then rewrite the unsafe parts following the query-performance-safety rules.