-
Notifications
You must be signed in to change notification settings - Fork 0
✨ Feat: 친구 최대 10명만 가능하도록 #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
nahjjun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전체적으로 N+1 문제만 해결하면 될 것 같습니다!! 코드 수정하느라 고생하셨습니다!!!
| .findBySenderAndStatus(sender, FriendRequestStatus.PENDING) | ||
| .stream() | ||
| .map(req -> FriendRequestListResDto.builder() | ||
| .requestId(req.getId()) | ||
| .userId(req.getReceiver().getId()) | ||
| .nickname(req.getReceiver().getNickname()) | ||
| .requestedAt(req.getCreatedAt()) | ||
| .build() | ||
| ) | ||
| .map(req -> { | ||
| User receiver = req.getReceiver(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FriendRequestRepository의 findBySenderAndStatus() 함수에서 JPQL로 Fetch Join으로 Receiver도 한번에 가져오는 것이 좋을 것 같습니다.
현재 구조에서는 매 FriendRequest에 연결되어있는 Receiver를 Lazy Loading으로 매번 쿼리문을 가져오기 때문에 n+1 문제가 우려됩니다. 해당 부분 수정해주시면 성능적으로 이점이 있을 것 같습니다!
| List<FriendResDto> friends = friendRepository.findByUser(user) | ||
| .stream() | ||
| .map(friend -> FriendResDto.builder() | ||
| .friendId(friend.getFriend().getId()) | ||
| .nickname(friend.getFriend().getNickname()) | ||
| .build() | ||
| ) | ||
| .map(friend -> { | ||
| var friendUser = friend.getFriend(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분도 위에서 언급한 것과 마찬가지로, findByUser 함수에서 Friend 엔티티도 Fetch Join으로 가져와야 N+1 문제가 생기지 않을 것 같습니다!
#️⃣연관된 이슈
📝작업 내용
📝 기타 참고사항