Skip to content

[Refactor] 질문 목록 조회 시 좋아요 여부 N+1 쿼리 개선 #161

Description

@kkw610

버그 설명

toQuestionSummaryResponse()에서 existsByQuestionAndUser()를 질문마다 한 번씩 호출하고 있어,
질문이 N개면 좋아요 조회 쿼리가 N번 나감

댓글 수/미리보기는 이미 배치로 개선되어 있는데 좋아요만 N+1로 남아 있어 일관성도 없음

작업 상세 내용

  • QuestionLikeRepository에 좋아요를 배치로 조회하는 메서드 추가
  • QuestionSummaryContext에 likedQuestionIds 필드 추가
  • getQuestionSummaryContext()에서 좋아요를 한 번에 조회하도록 수정
  • toQuestionSummaryResponse()에서 Set 조회로 변경

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions