Skip to content

![high](https://www.gstatic.com/codereviewagent/high-priority.svg) #215

@huhdy32

Description

@huhdy32

high

현재 스트림 내에서 각 problemId에 대해 problemQueryManager.getProblemInfo()를 호출하고 있습니다. 이는 문제집에 포함된 문제 수(N)만큼 쿼리를 실행하는 N+1 문제를 유발할 수 있습니다. 캐시가 적용되어 있지만, 캐시가 비어있는 초기 호출 시에는 성능 저하가 클 수 있습니다.

problemId 목록을 한 번에 조회하는 bulk API를 ProblemQueryManager에 추가하여 이 문제를 해결하는 것이 좋습니다. 예를 들어, 다음과 같이 리팩토링할 수 있습니다.

final List<Long> problemIds = solvedAssessment.getAssessmentItems().stream()
    .map(AssessmentItem::getProblemId)
    .toList();

// problemQueryManager에 problemIds를 인자로 받는 bulk 조회 메소드 추가 필요
final List<ProblemQueryResult> problemInfos = problemQueryManager.getProblemInfos(problemIds);

final List<ProblemSolutionResult> results = problemInfos.stream()
    .map(ProblemSolutionResult::from)
    .toList();

Originally posted by @gemini-code-assist[bot] in #213 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions