What problem does it solve?
Backend code often hides severe performance traps: loops that fire one SQL query per element (N+1), IN clauses with thousands of parameters, recursive traversals without node limits, and nested service calls that repeat the same heavy query. These issues pass local testing but degrade or crash production systems under real data volumes.
Core Features & Use Cases
- N+1 Detection and Remediation: Identifies single-record queries inside loops, streams, and DTO conversion helpers, then rewrites them using the batch-fetch-to-Map pattern with paired repository methods like findByIdIn.
- IN Clause Batching: Enforces a fixed IN_BATCH_SIZE of 500 for large ID lists, including batched SUM/COUNT aggregations, to avoid packet limits and plan-cache misses.
- Bounded Traversal and Query Reuse: Adds MAX_TOTAL_NODES caps with truncation logging to BFS/recursive walks, and consolidates nested service calls so one BFS result feeds count, sum, and list operations.
- Use Case: While reviewing a team-detail endpoint that calls countMembers, sumPoints, and listMembers separately, the Skill flags three duplicate BFS traversals and refactors them into a single shared descendant collection.
Quick Start
Review this service method for N+1 queries, unbatched IN clauses, and unbounded recursion, then rewrite it using batch fetching and Map lookups.