Skip to content

Conversation

tkguswls1106
Copy link
Member

@tkguswls1106 tkguswls1106 commented May 31, 2024

PULL REQUEST

🎋 Branch Name

refactor/#115

🔑 Main Contents

  • 'findByUserAndRoom(User user, Room room) -> findByUser_IdAndRoom_Id(Long userId, Long roomId)'로 수정.
    이를 통해 추가적인 DB 접근 조회를 최소화하며 보다 직관적인 코드로 작성 가능해짐.
  • EntityGraph 어노테이션을 활용한 N+1 문제 해결

==> 이러한 두가지 리팩토링을 통하여, DB 접근 성능을 보다 개선함.

🏞 Screenshots (Optional)

EntityGraph처리전후_SQL쿼리발생
기존 SQL 쿼리문 (쿼리 2번 발생) / N+1 해결후 SQL 쿼리문 (쿼리 1번 발생)

📋 Checks for reviewers (Optional)

@EntityGraph(attributePaths = {"room"})
Optional<UserRoom> findByUser_IdAndRoom_Id(Long userId, Long roomId);

이처럼 EntityGraph 어노테이션을 적용함으로써,
위의 스크린샷(적용전,적용후)처럼 기존에 발생하던 N+1 문제를 해결하였습니다.

@tkguswls1106 tkguswls1106 added the ♻️ Refactor 코드 리팩토링 label May 31, 2024
@tkguswls1106 tkguswls1106 requested a review from JunSang1121 May 31, 2024 12:58
@tkguswls1106 tkguswls1106 self-assigned this May 31, 2024
@tkguswls1106 tkguswls1106 linked an issue May 31, 2024 that may be closed by this pull request
Copy link
Collaborator

@JunSang1121 JunSang1121 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다. 고생하셨어요!!

@tkguswls1106 tkguswls1106 merged commit d5b177d into develop May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♻️ Refactor 코드 리팩토링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Refactor] N+1 문제 해결 및 JPA 쿼리 성능 개선
2 participants