-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
페이징으로 인해 일대다 관계는 fetch X
-> 한 요청 당 4개의 query가 요청됨. main / topic -> topickeyword / topickeyword -> keyword / topic -> choice)
# 1
SELECT t1_0.*,
a1_0.*
FROM topic t1_0
JOIN member a1_0
ON a1_0.id = t1_0.author_id
JOIN topic_keyword t2_0
ON t1_0.id = t2_0.topic_id
WHERE t1_0.status =?
AND NOT EXISTS(SELECT 1
FROM hidden_topic h1_0
WHERE h1_0.topic_id = t1_0.id
AND h1_0.member_id =? )
ORDER BY t1_0.vote_count DESC
LIMIT ?, ? lazy_loading -> batch 요청
# 2
select * from topic_keyword t1_0 where t1_0.topic_id in (?, ?)
# 3
select * from keyword k1_0 where k1_0.id in (?, ?)
# 4
select * from choice c1_0 where c1_0.topic_id in (?, ?)
!!! query를 topic_keyword를 기반으로 시작해도 main + 3 = 4번의 쿼리 나감