You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
위 사진에서 Review를 통해 ReviewTag까지는 가져올 수 있었지만, Tag는 못가져왔던 문제를 해결했어요
그래서 쿼리 14개가 날아가던걸 3개로 줄였습니다
최종적으로 개선된 쿼리 수 : 92개 → 14개 → 3개
쿼리문
Hibernate:
select
product0_.id as id1_4_0_,
product0_.average_rating as average_2_4_0_,
product0_.category_id as category8_4_0_,
product0_.content as content3_4_0_,
product0_.image as image4_4_0_,
product0_.name as name5_4_0_,
product0_.price as price6_4_0_,
product0_.review_count as review_c7_4_0_
from
product product0_
where
product0_.id=?
Hibernate:
select
review0_.id as col_0_0_,
member1_.nickname as col_1_0_,
member1_.profile_image as col_2_0_,
review0_.image as col_3_0_,
review0_.rating as col_4_0_,
review0_.content as col_5_0_,
review0_.re_buy as col_6_0_,
review0_.favorite_count as col_7_0_,
reviewfavo2_.favorite as col_8_0_,
review0_.created_at as col_9_0_
from
review review0_
inner join
member member1_
on review0_.member_id=member1_.id
left outer join
review_favorite reviewfavo2_
on review0_.id=reviewfavo2_.review_id
and (
reviewfavo2_.member_id=?
)
where
review0_.product_id=?
order by
review0_.created_at desc,
review0_.id desc limit ?
Hibernate:
select
reviewtag0_.id as id1_11_0_,
review1_.id as id1_9_1_,
tag2_.id as id1_12_2_,
reviewtag0_.review_id as review_i2_11_0_,
reviewtag0_.tag_id as tag_id3_11_0_,
review1_.content as content2_9_1_,
review1_.created_at as created_3_9_1_,
review1_.favorite_count as favorite4_9_1_,
review1_.image as image5_9_1_,
review1_.member_id as member_i8_9_1_,
review1_.product_id as product_9_9_1_,
review1_.rating as rating6_9_1_,
review1_.re_buy as re_buy7_9_1_,
tag2_.name as name2_12_2_,
tag2_.tag_type as tag_type3_12_2_
from
review_tag reviewtag0_
inner join
review review1_
on reviewtag0_.review_id=review1_.id
inner join
tag tag2_
on reviewtag0_.tag_id=tag2_.id
where
reviewtag0_.review_id in (
? , ? , ?
)
어떤 기능을 구현하나요?
#607 에서 완전히 해결하지 못했던 N+1 문제를 해결했습니다.
위 사진에서
Review
를 통해ReviewTag
까지는 가져올 수 있었지만,Tag
는 못가져왔던 문제를 해결했어요그래서 쿼리 14개가 날아가던걸 3개로 줄였습니다
쿼리문
응답 데이터
일정
The text was updated successfully, but these errors were encountered: