-
Notifications
You must be signed in to change notification settings - Fork 0
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
✨feature: Add isLike and itemLikeCount on Items Detail API #83
Conversation
|
||
public boolean isLiked(User user) { | ||
return likes != null ? | ||
likes.stream().anyMatch(like -> like.isLiked(user)) : false; |
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.
return likes != null && likes.stream().anyMatch(like -> like.isLiked(user));
이렇게 수정하는게 코드 가독성 측면에서 좀 더 좋은 것 같습니다.
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.
로직상에서는 큰 문제가 없지만 성능 상에 이슈가 발생해서, 일단 이번에는 테스트 코드를 작성해서, 머지를 하고 추후 성능 개선에 대해서 고민하고 추가 이슈를 진행하면 좋을 것 같습니다. select l1_0.item_id,l1_0.item_like_id,l1_0.created_at,l1_0.modified_at,l1_0.user_id from item_like l1_0 where l1_0.item_id=? 지금 쿼리를 확인하게 되면 Item id에 대해서 item Like 테이블로 조회를 하고 있는데, 만약 Item에 대해서 몇 10만개의 좋아요가 눌리게 되었다면, 서버에서는 몇 10만개의 유저와 비교해야 합니다. 데이터 베이스에서 조회비용, 네트워크 비용등의 많은 부분에서 성능 이슈가 발생하게 될 것 같습니다. 지금 아래와 같이 단순히 Hibernate: select i1_0.item_id,i1_0.album_cover_id,i1_0.content,i1_0.created_at,i1_0.modified_at,i1_0.song_id,i1_0.user_id from item i1_0 join item_location i2_0 on i2_0.item_id=i1_0.item_id where st_distance_sphere(i2_0.point,?)<=?
Hibernate: select i1_0.item_location_id,i1_0.created_at,i1_0.item_id,i1_0.modified_at,i1_0.name,i1_0.point,i1_0.village_id from item_location i1_0 where i1_0.item_id=?
Hibernate: select i1_0.item_location_id,i1_0.created_at,i1_0.item_id,i1_0.modified_at,i1_0.name,i1_0.point,i1_0.village_id from item_location i1_0 where i1_0.item_id=?
Hibernate: select u1_0.user_id,u1_0.created_at,u1_0.idfv,u1_0.modified_at,u1_0.nickname from users u1_0 where u1_0.user_id=?
Hibernate: select s1_0.song_id,s1_0.album_id,s1_0.created_at,s1_0.modified_at,s1_0.name from song s1_0 where s1_0.song_id=?
Hibernate: select a1_0.album_id,a1_0.album_cover_id,a1_0.artist_id,a1_0.created_at,a1_0.modified_at,a1_0.name from album a1_0 where a1_0.album_id=?
Hibernate: select a1_0.artist_id,a1_0.created_at,a1_0.modified_at,a1_0.name from artist a1_0 where a1_0.artist_id=?
Hibernate: select a1_0.album_cover_id,a1_0.album_image,a1_0.album_thumbnail,a1_0.created_at,a1_0.modified_at from album_cover a1_0 where a1_0.album_cover_id=?
Hibernate: select g1_0.song_id,g1_0.song_genre_id,g1_0.created_at,g1_0.genre_id,g1_0.modified_at from song_genre g1_0 where g1_0.song_id=?
Hibernate: select g1_0.genre_id,g1_0.created_at,g1_0.modified_at,g1_0.name from genre g1_0 where g1_0.genre_id=?
Hibernate: select g1_0.genre_id,g1_0.created_at,g1_0.modified_at,g1_0.name from genre g1_0 where g1_0.genre_id=?
Hibernate: select l1_0.item_id,l1_0.item_like_id,l1_0.created_at,l1_0.modified_at,l1_0.user_id from item_like l1_0 where l1_0.item_id=?
Hibernate: select u1_0.user_id,u1_0.created_at,u1_0.idfv,u1_0.modified_at,u1_0.nickname from users u1_0 where u1_0.user_id=?
Hibernate: select a1_0.album_cover_id,a1_0.album_image,a1_0.album_thumbnail,a1_0.created_at,a1_0.modified_at from album_cover a1_0 where a1_0.album_cover_id=?
Hibernate: select l1_0.item_id,l1_0.item_like_id,l1_0.created_at,l1_0.modified_at,l1_0.user_id from item_like l1_0 where l1_0.item_id=? |
84f3cc0
to
49aaaf4
Compare
Resolve: #82