Skip to content

Bug: AnalysisService N+1 query pattern in findOrphans() and findCoverageGaps() #318

@Brad-Edwards

Description

@Brad-Edwards

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions