Description
AnalysisService.findOrphans() and AnalysisService.findCoverageGaps() both load ALL requirements via requirementRepository.findAll(), then issue individual queries for each requirement to check relations/links. This is a textbook N+1 query problem.
Current behavior:
findOrphans(): loads N requirements, then for each checks if relations and links exist → N+1 queries
findCoverageGaps(): loads N requirements, then for each checks if a link of a specific type exists → N+1 queries
Expected behavior: Single SQL queries using NOT EXISTS subqueries to find requirements without relations/links in one round-trip.
Location: AnalysisService.java, methods findOrphans() and findCoverageGaps()
Traced Requirements
- GC-C003: Coverage Gap Analysis
- GC-C004: Orphan Detection
Impact
Performance — acceptable at small scale but will degrade linearly with requirement count.