Skip to content

Resolve N+1 Queries & Eager Fetching #3

Description

@viceda-s

Problem: WorkoutService suffers from massive N+1 queries during writes (looping .findById), and implicit Eager fetching causes N+1 on reads.

Acceptance Criteria:

  • Refactor WorkoutService.buildWorkoutExercises to fetch all exercises in a single query using exerciseRepository.findAllById(ids).
  • Change all @ManyToOne relationships (WorkoutPlan.owner, WorkoutExercise.exercise) to use fetch = FetchType.LAZY.
  • Update the WorkoutPlanRepository to use JOIN FETCH queries when loading plans to prevent lazy-loading N+1s during API serialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance and persistencetech-debtTechnical Debt

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions